[英]Ant JUnit Batchtest .java or .class
I have seen a few links which appears to imply that JUnit tests can be executed from the .java file instead of the .class 我看到一些链接似乎暗示JUnit测试可以从.java文件而不是.class执行
For example 例如
<junit printsummary="yes" haltonfailure="yes" haltonerror="yes">
<classpath refid="ui.tests.classpath"/>
<formatter type="xml"/>
<batchtest todir="${env.WORKSPACE}/UITests/output">
<fileset dir="${ui.tests.classes}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
Instead of 代替
<junit printsummary="yes" haltonfailure="yes" haltonerror="yes">
<classpath refid="ui.tests.classpath"/>
<formatter type="xml"/>
<batchtest todir="${env.WORKSPACE}/UITests/output">
<fileset dir="${ui.tests.classes}">
<include name="**/*Test.class"/>
</fileset>
</batchtest>
</junit>
Is the first example a valid case? 第一个例子是有效的案例吗? I could not get it working due to ClassNotFoundExceptions
由于ClassNotFoundExceptions,我无法使它工作
I agree with the comment above, that it looks like the tag allows for either .java or .class. 我同意上面的评论,看起来标签允许.java或.class。
I did a small test and when I ran a test with this setup - where the dir=somefolder
, then using <include name="**/*Test.java"/>
when the folder pointed at contains class files, then Ant will basically have an empty fileset to process for *Test.java, but when using <include name="**/*Test.class"/>
then the fileset was not empty and the test cases will get run. 我做了一个小测试,当我使用这个设置运行测试 - 其中
dir=somefolder
,然后当指向的文件夹包含类文件时使用<include name="**/*Test.java"/>
,然后Ant将基本上有一个空的文件集来处理* Test.java,但是当使用<include name="**/*Test.class"/>
,文件集不是空的,测试用例将会运行。
This was the result of my quick test. 这是我快速测试的结果。 As far as I could tell, it looks like you need to specify the *Test.class to pickup the test cases.
据我所知,看起来你需要指定* Test.class来拾取测试用例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.