如何通过Ant显示jUnit错误
我正在尝试向公司的项目中添加一个Ant脚本来运行jUnit测试。以下是我所拥有的:如何通过Ant显示jUnit错误,ant,junit,Ant,Junit,我正在尝试向公司的项目中添加一个Ant脚本来运行jUnit测试。以下是我所拥有的: <target name="unit-tests"> <junit> <classpath> <pathelement location="${project.libext.dir}/junit-4.1.jar"/> </classpath> <batchtest>
<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
标记(printsummmary
,showoutput
,等等)添加一些属性,但似乎找不到正确的组合。我能得到的最好结果是:
[junit] Running package.MyTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
我确实需要完整的堆栈跟踪等,因为当我通过Eclipse运行as>Junit测试时,测试运行良好
有人知道如何进行堆栈跟踪打印吗 不能在Ant输出AFAIK中打印测试的完整堆栈跟踪;它嵌入在JUnit报告文件中。您可以单独浏览,或者如果您正在使用Jenkins或CruiseControl等持续集成服务器来运行构建,您可以设置一个将链接到测试报告的插件。找到了答案。需要添加格式化程序
<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>
如何确定jUnit报告文件的位置?我猜测batchtest
标记上的todir
属性,但这似乎没有创建任何内容。
<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>