简体   繁体   English

Jacoco 蚂蚁任务 - 没有 jacoco.exec 输出

[英]Jacoco ant task - no jacoco.exec output

I configured my Ant task as我将我的 Ant 任务配置为

<target name="test" depends="init">
    <jacoco:coverage destfile="target/jacoco.exec">
        <junit printsummary="yes" haltonfailure="yes" fork="yes" forkmode="once">
            <classpath refid="my_project.path"/>
            <formatter type="plain"/>
            <formatter type="xml"/>
            <batchtest fork="false" todir="target/test-reports">
                <fileset dir="test">
                    <include name="**/*Test.java"/>
                </fileset>
            </batchtest>
        </junit>
    </jacoco:coverage>
</target>

Which produces the expected junit result.这会产生预期的junit 结果。 However, the target/jacoco.exec is never created.但是,永远不会创建target/jacoco.exec I do not have any error during the ant test report task execution.我在ant test report任务执行过程中没有任何错误。

test: [jacoco:coverage] Enhancing junit with coverage测试:[jacoco:coverage] 通过覆盖增强 junit

 ... [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0,009 sec

report: [jacoco:report] Loading execution data file /home/usr/Workspaces/my_project/target/jacoco.exec报告:[jacoco:report] 正在加载执行数据文件 /home/usr/Workspaces/my_project/target/jacoco.exec

BUILD FAILED /home/usr/Workspaces/my_project/build.xml:73: Unable to read execution data file /home/usr/Workspaces/my_project/target/jacoco.exec构建失败 /home/usr/Workspaces/my_project/build.xml:73: 无法读取执行数据文件 /home/usr/Workspaces/my_project/target/jacoco.exec

Total time: 14 seconds总时间:14秒

Seems like I am missing something, unable to see what exactly.好像我错过了一些东西,无法看到究竟是什么。

I found the cause.我找到了原因。 It is stupid but there was no logging to indicate the error:这很愚蠢,但没有记录来指示错误:

batchtest fork="true" todir="target/test-reports" batchtest fork="true" todir="target/test-reports"

The fork parameter was set to false in the batchtest.在批处理测试中 fork 参数设置为 false。 Setting it back to "true" produces the expected jacoco.exec .将其设置回“true”会产生预期的jacoco.exec

Running the report task by itself is not sufficient.单独运行report任务是不够的。 You will have to configure and run a coverage Ant task in order to enable coverage data to be recorder into the jacoco.exec file.您必须配置并运行一个coverage Ant 任务,以便将覆盖数据记录到jacoco.exec文件中。 See here这里

Faced the same issue, for me my junit wasn't proper.面临同样的问题,对我来说,我的 junit 不合适。 Follow the link here按照这里的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM