What these two tags represent in a Pitest XML report?

Viewed 78

I am currently trying to extract mutations generated from tools' reports, and I'm currently struggling with Pitest.

Given an XML Pitest report, it has a mutation list; each mutation element has n attributes, including index and block, which I cannot understand what they represent.

Excluding them, I have a problem of mutation overlapping, i.e. two different mutations have the same parameters; including them, I don't have this problem.

What does they represent?

This is an example of a report with two colliding mutations:

<?xml version="1.0" encoding="UTF-8"?>
<mutations>
<mutation detected='false' status='SURVIVED' numberOfTestsRun='2'><sourceFile>HelpFormatter.java</sourceFile><mutatedClass>org.apache.commons.cli.HelpFormatter</mutatedClass><mutatedMethod>renderOptions</mutatedMethod><methodDescription>(Ljava/lang/StringBuffer;ILorg/apache/commons/cli/Options;II)Ljava/lang/StringBuffer;</methodDescription><lineNumber>786</lineNumber><mutator>org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_ELSE</mutator><index>122</index><block>37</block><killingTest/><description>removed conditional - replaced equality check with false</description></mutation>
<mutation detected='false' status='SURVIVED' numberOfTestsRun='1'><sourceFile>HelpFormatter.java</sourceFile><mutatedClass>org.apache.commons.cli.HelpFormatter</mutatedClass><mutatedMethod>renderOptions</mutatedMethod><methodDescription>(Ljava/lang/StringBuffer;ILorg/apache/commons/cli/Options;II)Ljava/lang/StringBuffer;</methodDescription><lineNumber>786</lineNumber><mutator>org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_ELSE</mutator><index>125</index><block>39</block><killingTest/><description>removed conditional - replaced equality check with false</description></mutation>
</mutations>

And this is the Java line that caused these two mutations:

if (argName != null && argName.length() == 0)
1 Answers

According to javadocs on pitest,

https://github.com/hcoles/pitest/blob/90d5df53a32c62f78695232410ab2e2009cd82b9/pitest/src/main/java/org/pitest/mutationtest/engine/MutationDetails.java#L202-L208
index is the index to the ... instruction on which this mutation occurs. This index is specific to how ASM represents the bytecode.

https://github.com/hcoles/pitest/blob/90d5df53a32c62f78695232410ab2e2009cd82b9/pitest/src/main/java/org/pitest/mutationtest/engine/MutationDetails.java#L171-L177
block is basic block in which this mutation occurs.

https://github.com/hcoles/pitest/issues/131#issuecomment-47398717
block based means coverage is tracked per non-branching code block. Oversimplified this can be seen as coverage is recorder per pair of curly braces. If you don't have any control flow statement inside a method there is just one block. If you have an if statement (without else) there will be up to 3 blocks (one before the if statement, the "then" part of the if statement and one block after the if statement and so on).

Related