I am trying to add an Ant script to my company's project to run the jUnit tests. Here is what I have:
<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>
The script is grabbing my jUnit tests correctly, but it's saying there are errors. But all the output will say is things like:
[junit] Test package.MyTest FAILED
I want to know why it failed. I have tried adding a bunch of the attributes to the junit
tag (printsummary
, showoutput
, etc), but can't seem to find the right combination. The best I have managed to get is:
[junit] Running package.MyTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
I really need the full stack trace, etc as the test runs fine when I Run As > Junit Test via Eclipse.
Anyone know how to make the stack trace print?
Found the answer. Needed to add a formatter.
You can't print the full stack trace from the tests in the Ant output AFAIK; it's embedded in the JUnit report file. You can either browse that separately, or if you're using a continuous integration server such as Jenkins or CruiseControl to run your builds, you can set up a plugin that will link to the test reports.