Tuesday, June 29, 2004

Ant Junit Task mishandles Suites

Maybe I'm missing something, but the Ant Junit task doesn't seem to handle Suites well. What I mean is that the formatters supplied with the base Junit task, when outputting information about a suite, don't spit out details about the class that a test was in. So can't even display this information in the html.

For instance if I had two tests, one in TestClass1 and another in TestClass2 named testMyMethod() and run from the suite AllTests, the output from not distinguish between the two tests.

The "work around" is to use the nested element and specify a:
<fileset includes="**/*.class" excludes="**/AllTests.class" />
However, this runs slower than using test suites.

I did see that in 1.6.2 there will be a new option to fork a single JVM instead of one for each class, but even then this could run faster through test suites.

So for now I have added a vote to bug #24106. I encourage anyone else that is annoyed by this to do the same!


Anonymous said...


I have the same problem. I have a GlobalTestSuite that collects are Test Classes and adds each one to the global suite. The global suite is in turn decorated by a setup object which initializes a JNDI server, database pool, environment variables, etc...

The report ends up showing only one package and one class - the global class. It seems that the JUnit task only cares about the classes that are actually specified in the task itself, not what is contained within the actual class.

Did you ever find a way around this?

Jeff Sheets said...

Well, to be honest, this was a couple of years ago and I have since moved on. I would look into the bug that I had linked, and try the fork jvm switch. Good luck, and post here if you find a solution.