ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Samuel Langlois" <>
Subject JUnit task and test suites
Date Mon, 25 Aug 2003 12:59:01 GMT

We use Ant's junit task to run dynamically generated TestSuite.
(We need to perform tests against several databases, and we don't
want to repeat the testing code for each database).
Here is a very simplified version of the code:

import junit.framework.*;
public class GeneratedSuite {
  // Parameterized suite
  public static Test suite(String s) {
    TestSuite suite = new TestSuite();
    suite.addTest( new TestCase("Testing "+s) { protected void runTest() {} } );
    return suite;
  // Top-level suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest( suite("Suite A") );
    suite.addTest( suite("Suite B") );
    return suite;

Although this is correctly executed, Ant's JUnit test runner "flattens"
the test structure, and we end up with all test cases at the same level.
Actually, the junit task only records the Java structure (packages + classes)
and does not care about the JUnit structure (TestSuite + TestCase).
Other testrunners, such as junit.swingui.TestRunner, manage to
keep the TestSuite hierarchy.

Any advice to workaround this limitation?



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message