The following snippet, from another thread, works to print a message and fail after all unit tests have been run :
<fail if="junit.failed" message="Oh no ! There were some failed unit tests :( "/>
However --- I don't see a how can I also record and print the NAMES of the failed tests in junit/ant, after they have all run. Any thoughts on this ?
I believe others would find such function extremely important, so I'm assuming a simple solution exists : its quite tedious to look through hundreds of failed tests for the offenders.
I'm sure that many of you have no desire to build a custom formatter or whatever. I don't either. I discovered that, with the following configuration, test successes are printed to stdout while failures are printed to stderr:
That means that running the following command:
will only show stderr with the test failures to the console, making it much easier to see what actually failed.
Yes it is. Try using the junitreport task.
e.g.
Try this attribute on your junit task:
printsummary="yes"
on junit taskChange your formatter to:
and then create the reports with a target that calls this:
For output :
I think I finally have a complete answer to this question : Thanks to FailedDev's insights .
First, Make sure you ${reports.dir} variable, specifying the directory for the reports :
Then , when we begin coding the test instructions junit :
Then, make necessary directories for the reports :
Since we have a report scanner, we can set haltonfailure to no, and fail after (scroll down).
Now, here is where the advice of other questions comes in : run the junit report.
And finally, we can grep the xml files, directly, for errors :
Now, since we are'nt failing early (rather we are running the whole build, so we can see which tests failed , if any) we still have to notify the builder that we have failed... This is done via the fail-if syntax :
Removing my comments, this code-block should work perfectly if you paste it into your build.