gpt4 book ai didi

ant - 如何通过 Ant 显示 jUnit 错误

转载 作者:行者123 更新时间:2023-12-04 23:27:43 25 4
gpt4 key购买 nike

我正在尝试将 Ant 脚本添加到我公司的项目中以运行 jUnit 测试。这是我所拥有的:

<target name="unit-tests">
<junit>
<classpath>
<pathelement location="${project.libext.dir}/junit-4.1.jar"/>
</classpath>
<batchtest>
<fileset dir="${project.src-test.dir}/my/company/." />
</batchtest>
</junit>
</target>

该脚本正确地抓取了我的 jUnit 测试,但它说存在错误。但是所有的输出都会说是这样的:

[junit] Test package.MyTest FAILED

我想知道为什么失败了。我尝试将一堆属性添加到 junit 标签(printsummaryshowoutput 等),但似乎找不到正确的组合。我设法得到的最好的是:

[junit] Running package.MyTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

我真的需要完整的堆栈跟踪等,因为当我通过 Eclipse Run As > Junit Test 时测试运行良好。

有人知道如何打印堆栈跟踪吗?

最佳答案

找到答案了。需要添加格式化程序。

<target name="unit-tests">
<junit>
<classpath>
<pathelement location="${project.libext.dir}/junit-4.1.jar"/>
</classpath>
<formatter type="plain" usefile="false" />
<batchtest>
<fileset dir="${project.src-test.dir}/my/company/." />
</batchtest>
</junit>
</target>

关于ant - 如何通过 Ant 显示 jUnit 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11746177/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com