jeudi 19 novembre 2020

What does the "number", "firstInstruction", "lastInstruction" stand for in the Pit test lineCoverage report?

I am using Pitest for mutation testing for Java projects, but also want to use the line coverage feature, to extract each test method's individual line coverage information. When I run Pitest and generate the lineCoverge.xml report, there are three attributes in the report that I couldn't figure out. These attributes are "number", "firstInstruction" and "lastInstruction".

FYI: I used JaCoCo and EclEmma for extracting coverage information. However, these run as a single process so all the tests run at once. Therefore, you cannot extract each test method's coverage information. You have to comment out and leave one test method open, run the test and export the coverage information. So, if you have 100 test, you are going to redo this process 100 times, which is not convenient. I believe Pitest does that. But if you know such framework or tool that does that, I am open to give it a try! I also didn't understand why there are duplicate lines (see report example below).

Below I am sharing a sample output of my pitest line coverage report.

<block classname='org.apache.commons.csv.CSVFormat' method='format([Ljava/lang/Object;)Ljava/lang/String;' number='13' firstInstruction='64' lastInstruction='70'><tests>
<test name='org.apache.commons.csv.CSVFormatTest.testFormatThrowsNullPointerException()'/>
</tests>
</block>
<block classname='org.apache.commons.csv.CSVFormat' method='format([Ljava/lang/Object;)Ljava/lang/String;' number='13' firstInstruction='64' lastInstruction='70'><tests>
<test name='org.apache.commons.csv.CSVFormatTest.testFormatThrowsNullPointerException()'/>
</tests>
</block>
<block classname='org.apache.commons.csv.CSVFormat' method='format([Ljava/lang/Object;)Ljava/lang/String;' number='13' firstInstruction='64' lastInstruction='70'><tests>
<test name='org.apache.commons.csv.CSVFormatTest.testFormatThrowsNullPointerException()'/>
</tests>
</block>
<block classname='org.apache.commons.csv.CSVFormat' method='format([Ljava/lang/Object;)Ljava/lang/String;' number='13' firstInstruction='64' lastInstruction='70'><tests>
<test name='org.apache.commons.csv.CSVFormatTest.testFormatThrowsNullPointerException()'/>
</tests>
</block>
<block classname='org.apache.commons.csv.CSVFormat' method='format([Ljava/lang/Object;)Ljava/lang/String;' number='13' firstInstruction='64' lastInstruction='70'><tests>
<test name='org.apache.commons.csv.CSVFormatTest.testFormatThrowsNullPointerException()'/>
</tests>
</block>
<block classname='org.apache.commons.csv.CSVFormat' method='format([Ljava/lang/Object;)Ljava/lang/String;' number='13' firstInstruction='64' lastInstruction='70'><tests>
<test name='org.apache.commons.csv.CSVFormatTest.testFormatThrowsNullPointerException()'/>
</tests>
</block>
<block classname='org.apache.commons.csv.CSVFormat' method='format([Ljava/lang/Object;)Ljava/lang/String;' number='13' firstInstruction='64' lastInstruction='70'><tests>
<test name='org.apache.commons.csv.CSVFormatTest.testFormatThrowsNullPointerException()'/>
</tests>
</block>
<block classname='org.apache.commons.csv.CSVFormat' method='format([Ljava/lang/Object;)Ljava/lang/String;' number='15' firstInstruction='73' lastInstruction='76'><tests>
<test name='org.apache.commons.csv.CSVFormatTest.testFormatThrowsNullPointerException()'/>
</tests>
</block>
...

Aucun commentaire:

Enregistrer un commentaire