Domanda

I am new to JaCoCo and trying to figure out why the html report that I am generating is not linked with my source.

The coverage numbers look correct and I can browse down to each class and then each method but I can not see the source. I have tried many different things inside the sourcefiles tag but nothing is working. Has anyone else had this issue? Here is a snippet of my ant script:

...

   <test name="test.fw.UITestSuite" todir="${logdir}"/>
    </junit>
    </jacoco:coverage>
    <fail if="TestFailed" status="1" message="UI junit test failure detected"/>
    <echo message="${src}"/>
    <jacoco:report>                                
        <executiondata>
            <file file="jacoco.exec"/>
        </executiondata>                            
        <structure name="UI">
            <classfiles>
                <fileset dir="${build}/fw"/>
            </classfiles>
            <sourcefiles encoding="UTF-8">
                <fileset dir="fw" includes="**./*.java"/>
            </sourcefiles>
        </structure>                                
        <html destdir="report"/>                                
    </jacoco:report>
</target>

...

È stato utile?

Soluzione

Your fileset definition seems odd.

The include must be (the first . is misplaced):

includes="**/*.java

Try simply pointing it to the root of your src dir (there is no need for the includes)

<fileset dir="fw"  />

But fw has to be the root of your sources, i.e. it contains the package folders like:

src
 -org
   -module
     -MyClass1.java
     -MyClass2.java

Altri suggerimenti

I’ve seen this break when using Scala-style package directory names, e.g.,

src/main/java/com.example.foo.bar/Foo.java

for fewer levels of nesting, faster autocompletion, &c., compared to the standard

src/main/java/com/example/foo/bar/Foo.java

Most tools support the first version just fine, but usually if you try it out and everything works fine, by the time you notice something like the jacoco reports not showing the source anymore, you’ve long forgotten the directory name change …

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top