vendredi 17 avril 2020

test case priortization. How can I obtain test case code coverage?

I'm working on a Java project and i'm interested in implementing a test case prioritization algorithm. To be more specific the "additional strategy". This is a coverage-based algorithm. That means that test cases are prioritized based on how much code they cover. What i'm having trouble with is finding a tool that can give me individual test case coverage rather than project coverage. I've looked at JaCoCo and OpenClover these tools provide some of the information but there seem to be no way to tie a given test to statements and/or methods in the project code.

In order to clarify, please look at the XML below.

 <project name="myProj">
    <metrics  methods="2" classes="2" statements="15" packages="1" />
    <file path="F:\myProj\src\java\Main.java" name="Main.java">
        <metrics  methods="2" classes="2" statements="15" packages="1" />
    </file>
 </project>

<file path="F:\myProj\src\test\java\Test.java" name="Test.java">
    <class name="Test">
       <metrics methods="2" testruns="2" statements="6" coveredmethods="2" coveredstatements="9" testpasses="2"/>
       <method name ="palindromTest">
            <metrics statements="3" coveredmethods="1" coveredstatements="4" passed="true" file="StringManipulation.java"/>
            <statement line="1"/>
            <statement line="2"/>
            <statement line="3"/>
            <statement line="4"/>
       </method>
        <method name ="stringReverseTest">
            <metrics statements="3" coveredmethods="1" coveredstatements="5" passed="true" file="StringManipulation.java"/>
            <statement line="3"/>
            <statement line="4"/>
            <statement line="5"/>
            <statement line="6"/>
            <statement line="7"/>
       </method>
    </class>
</file> 

This is an example of what I want. from this I can see that the method palindromTest covers 4 statements. I know that two of those statements are also covered by stringReverseTest. I can also see that the palindromTest covers 4 / 15 statements in the source code making it's statement coverage 26 % or 13 % unique coverage. This is the type of information I need. However finding a tool that does this seem impossible.

Aucun commentaire:

Enregistrer un commentaire