我无法获得jacoco/junit ant目标以从覆盖范围中排除类.我可以通过这样的方式来排除包:
<jacoco:coverage destfile="${coverage.reports.dir.xml}/output.jacoco" excludes="foo.*:bar.fiz.*:my.long.package.name.*">
Run Code Online (Sandbox Code Playgroud)
这并不排除我的测试类,因为测试类与它们测试的类在同一个包中.我已经厌倦了用正则表达式排除测试类,但它不起作用.
<jacoco:coverage destfile="${coverage.reports.dir.xml}/output.jacoco" excludes="foo.*:bar.fiz.*:**/Test.*:**/Tests.*">
Run Code Online (Sandbox Code Playgroud)
我还尝试在报告任务中包含我想要的类,但由于我们的测试类位于不起作用的相同包中.我们的构建将所有类放在同一目录中,例如buildRoot/classes/ProjectName.因此buildRoot/classes/ProjectName/foo将包含测试和非测试类的编译类.
有关如何让jacoco排除此设置中的所有测试的任何建议吗?
谢谢.
adh*_*amh 23
指定类jacoco:coverage
将它们从coverage中排除,因此它们在报告中显示为0%覆盖率.
为了从JaCoCo报告中排除这些类,您需要使用classfiles文件集任务并将其排除在jacoco:report
ant任务中.
<jacoco:report>
<executiondata>
<file file="${coverage.reports.dir.xml}/merged-jacoco.exec"/>
</executiondata>
<structure name="Unit Tests ${unit.test.run.ts}">
<classfiles>
<fileset dir="${build.root}/classes/ProjectName/" >
<exclude name="**/*Test*.class" />
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.root}/ProjectName/src/main"/>
</sourcefiles>
</structure>
<html destdir="${coverage.reports.dir.html}"/>
</jacoco:report>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7374 次 |
最近记录: |