I have inherited some code which runs a suite of JUnittest cases (via junit.textui.TestRunner.doRun(mySuite)) and outputs the results of the test case either as "." for a success, or ".F" for a failure, followed by the errors and a summary of the run results. So if I have three test cases which run at once, and the first and third succeed, then the output file looks like "..F." followed by the errors and a summary of how many successes/failures. What I would like instead is to have the report look something like this:
I have looked at the JavaDoc for junit.textui.TestRunner and there is no way to specify how the final report comes out, more specifically no way to tell it to print the name of the test case and the result rather than either "." for success or ".F" for failures.
Can anyone advise me how I can modify this behavior? Am I stuck and just need to write a parser to convert the "..F." to a meaningful report as to which tests succeeded or failed (as in the above example)?
It is possible to write your own TestListener implementation to get notification about each test that runs, but if I were you, I would look at the reporting capabilities that are built into the Ant JUnit tasks. See ant.apache.org to learn about Ant if you're not already using it.
Thanks for the pointer. I am using <junit> and <junitreport> in tandem now and it gives me much better output!
Joined: Sep 12, 2003
One thing further on this topic -- I ran my test suite with the full battery of test cases (~80) and my machine ran out of memory (java.lang.OutOfMemoryError: Java heap space). So I added the fork option (I tried both fork="yes" and fork="on") and when I run the tests after that modification to the build.xml I get only a single test which fails almost immediately. The error I see in the log file tells me that there's an InvocationTargetException:
If I remove the fork option everything goes back to normal and the tests all run OK (assuming I abbreviate the number of tests being run to 10-20 test cases per run).