samedi 25 janvier 2020

How to form a mapping between test cases and the class on which it ran?

I am trying to map which test case (defined under src/test/java) ran on which classes (defined under src/main/java)

I tried examining the Jacoco Report and Testng report but failed to find a correlation between the test cases (Unit test functions) and the classes on which it tests

Here I am trying to find and build a tree on which test cases ran on which classes

Something like in the pic here

See this image about the mapping

test1 , test2, test3 ran on class AppFeature

and test4 ran on class AppLogin

My Project Structure Here's the testng report (in xml)

<?xml version="1.0" encoding="UTF-8"?>
<testng-results skipped="0" failed="0" ignored="0" total="2" passed="2">
    <reporter-output></reporter-output>
    <suite name="TestLogin.AppLoginTest" duration-ms="48" started-at="2020-01-23T12:38:24Z" finished-at="2020-01-23T12:38:24Z">
        <groups></groups>
        <test name="Command line test" duration-ms="48" started-at="2020-01-23T12:38:24Z" finished-at="2020-01-23T12:38:24Z">
            <class name="TestLogin.AppLoginTest">
                <test-method status="PASS" signature="test1()[pri:0, instance:TestLogin.AppLoginTest@5bb8f9e2]" name="test1" duration-ms="10" started-at="2020-01-23T12:38:24Z" finished-at="2020-01-23T12:38:24Z">
                    <reporter-output></reporter-output>
                </test-method>
                <!-- test1 -->
                <test-method status="PASS" signature="test2()[pri:0, instance:TestLogin.AppLoginTest@5bb8f9e2]" name="test2" duration-ms="0" started-at="2020-01-23T12:38:24Z" finished-at="2020-01-23T12:38:24Z">
                    <reporter-output></reporter-output>
                </test-method>
                <!-- test2 -->
            </class>
            <!-- TestLogin.AppLoginTest -->
        </test>
        <!-- Command line test -->
    </suite>
    <!-- TestLogin.AppLoginTest -->
</testng-results>

and here's the Jacoco Report (in xml)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN" "report.dtd">
<report name="Jacoco Login Test">
    <sessioninfo id="something" start="1579779554228" dump="1579779554824"/>
    <sessioninfo id="something" start="1579782945614" dump="1579782946183"/>
    <sessioninfo id="something" start="1579783104434" dump="1579783105003"/>
    <package name="Login">
        <class name="Login/AppLogin">
            <method name="&lt;init&gt;" desc="()V" line="3">
                <counter type="INSTRUCTION" missed="0" covered="3"/>
                <counter type="LINE" missed="0" covered="1"/>
                <counter type="COMPLEXITY" missed="0" covered="1"/>
                <counter type="METHOD" missed="0" covered="1"/>
            </method>
            <method name="login" desc="(Ljava/lang/String;Ljava/lang/String;)Z" line="9">
                <counter type="INSTRUCTION" missed="6" covered="19"/>
                <counter type="BRANCH" missed="4" covered="4"/>
                <counter type="LINE" missed="1" covered="6"/>
                <counter type="COMPLEXITY" missed="3" covered="2"/>
                <counter type="METHOD" missed="0" covered="1"/>
            </method>
            <counter type="INSTRUCTION" missed="6" covered="22"/>
            <counter type="BRANCH" missed="4" covered="4"/>
            <counter type="LINE" missed="1" covered="7"/>
            <counter type="COMPLEXITY" missed="3" covered="3"/>
            <counter type="METHOD" missed="0" covered="2"/>
            <counter type="CLASS" missed="0" covered="1"/>
        </class>
        <sourcefile name="AppLogin.java">
            <line nr="3" mi="0" ci="3" mb="0" cb="0"/>
            <line nr="9" mi="0" ci="2" mb="0" cb="0"/>
            <line nr="11" mi="0" ci="8" mb="1" cb="3"/>
            <line nr="13" mi="0" ci="2" mb="0" cb="0"/>
            <line nr="14" mi="0" ci="1" mb="0" cb="0"/>
            <line nr="16" mi="4" ci="4" mb="3" cb="1"/>
            <line nr="18" mi="2" ci="0" mb="0" cb="0"/>
            <line nr="21" mi="0" ci="2" mb="0" cb="0"/>
            <counter type="INSTRUCTION" missed="6" covered="22"/>
            <counter type="BRANCH" missed="4" covered="4"/>
            <counter type="LINE" missed="1" covered="7"/>
            <counter type="COMPLEXITY" missed="3" covered="3"/>
            <counter type="METHOD" missed="0" covered="2"/>
            <counter type="CLASS" missed="0" covered="1"/>
        </sourcefile>
        <counter type="INSTRUCTION" missed="6" covered="22"/>
        <counter type="BRANCH" missed="4" covered="4"/>
        <counter type="LINE" missed="1" covered="7"/>
        <counter type="COMPLEXITY" missed="3" covered="3"/>
        <counter type="METHOD" missed="0" covered="2"/>
        <counter type="CLASS" missed="0" covered="1"/>
    </package>
    <counter type="INSTRUCTION" missed="6" covered="22"/>
    <counter type="BRANCH" missed="4" covered="4"/>
    <counter type="LINE" missed="1" covered="7"/>
    <counter type="COMPLEXITY" missed="3" covered="3"/>
    <counter type="METHOD" missed="0" covered="2"/>
    <counter type="CLASS" missed="0" covered="1"/>
</report>

Aucun commentaire:

Enregistrer un commentaire