ant junit 未运行带有测试目标的单一方法
我有一个运行 Ant 版本 1.10.6 的构建系统 我在下面总结的宏定义被构造为打开“run.multi”,它要么运行单个测试方法,要么执行其他操作(我没有将其包括在内,因为它不相关)。 我这里遇到的问题是,我无法让它只运行一种方法“test.method” - 我已经打开了详细功能,可以看到它全部进入并正确设置,但无论如何它都会运行所有方法!
<echo level="info" message="Single method=@{test.method}" />
<junit printsummary="on" showoutput="true" fork="yes" forkmode="once">
<assertions>
<enable/>
</assertions>
<test unless="${run.multi}"
name="@{test.single}"
methods="@{test.method}"
haltonfailure="no"
haltonerror="no">
<formatter type="plain" usefile="false"/>
</test>
这是输出的一部分:
[echo] Single method=testSimple
[junit] Running com.test.util.TheTestToRun
[junit] Testsuite: com.test.util.TheTestToRun
[junit] Running on Java 9.0.4
[junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.473 sec
I've got a build system running Ant Version 1.10.6
The macrodef that I've summarised below is constructed to switch on "run.multi" either it runs a single test method or it does something else (which i've not included as its not relevant).
The issue I have here is that I cannot get it to run just the one method 'test.method' - I've turned the verbose on and can see it all going in and being set correctly, but it runs all the methods regardless!
<echo level="info" message="Single method=@{test.method}" />
<junit printsummary="on" showoutput="true" fork="yes" forkmode="once">
<assertions>
<enable/>
</assertions>
<test unless="${run.multi}"
name="@{test.single}"
methods="@{test.method}"
haltonfailure="no"
haltonerror="no">
<formatter type="plain" usefile="false"/>
</test>
And here is a portion of the output:
[echo] Single method=testSimple
[junit] Running com.test.util.TheTestToRun
[junit] Testsuite: com.test.util.TheTestToRun
[junit] Running on Java 9.0.4
[junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.473 sec
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发生这种情况的原因要么是 ant 中的一个错误,要么是一个功能 - 围绕 junit 部分的 fork 选项。设置“fork=no”,问题就消失了:
输出的一部分:
The reason that this was happening is either a bug or a feature in ant - around the fork option on the junit section. set 'fork=no' and the issue goes away:
A portion of the output: