我有一个脚本(test.bat),该脚本允许我通过命令行启动一个Java测试: -java -cp()org.junit.runner.JUnitCore包.Class
I have a script(test.bat) that allows me to launch one java test by command line : -java -cp() org.junit.runner.JUnitCore package.Class
现在我想对几个Java测试做同样的事情吗? 我该怎么办?我是否必须为每个Java测试添加字节码? 请给我一个例子吗?
Now I want to do the same for several java tests ? how could I do it? should I have to add the byte code for each java test? could I have an example , please?
推荐答案您可以使用Ant使用junit ant任务通过单个命令运行测试.这是一个有关如何使用它的示例:
You can use Ant to run your tests with a single command with the junit ant task. Here's an example on how to use it:
<target name="runtests" depends="clean,compiletests"> <junit printsummary="yes" haltonfailure="no"> <classpath> <path refid="test.classpath" /> <pathelement location="${test.classes}"/> </classpath> <formatter type="xml"/> <batchtest fork="yes" todir="${test.reports}"> <fileset dir="${test.src}"> <include name="**/*Test*.java"/> </fileset> </batchtest> </junit> </target>该目标使用batchtest,这是junit ant任务的一部分.它设置了您的测试类路径,因此将包括所有在类名中包含 Test .java模式的测试.查看 JUnit任务文档.
That target uses batchtest which is part of the junit ant task. It sets your test classpath so all your tests that contain the Test.java pattern in their class name will be included. Check out the JUnit Task documentation.
更多推荐
junit测试套件
发布评论