You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by jason r tibbetts <ti...@verdi.iisd.sra.com> on 2007/03/13 21:29:32 UTC

Surefire 2.3 ignores suite()?

I'm using Surefire 2.3 to test with JUnit 4, and it seems as though my 
tests' suite() methods aren't being used by the Surefire booter. Does it 
simply look for the "@Test"-annotated tests manually?

I'm using suite() because I have a couple of Parameterized tests 
implemented as inner classes of another (non-Parameterized) test, and 
I'd like the outermost test class's suite() to add the Parameterized 
tests to it, like so:

public class FooTest {

   public static junit.framework.Test suite() {
     TestSuite suite = new JUnit4TestAdapter(FooTest.class);
     suite.addTest(new JUnit4TestAdapter(BarParamTest.class));
     suite.addTest(new JUnit4TestAdapter(BatParamTest.class));

     return suite;
   }

   @RunWith (value = Parameterized.class)
   public static class BarParamTest {
     ...
   }

   @RunWith (value = Parameterized.class)
   public static class BatParamTest {
     ...
   }
}

This is partly to keep all tests related to Foo in the same file 
(whether they're parameterized or not), and partly because Surefire 
excludes inner classes. I could make sure that my inner classes are 
named *Test and add a pattern like "**/*$*Test.class" to my includes, 
but that's not as obvious to future maintainers that that's how the 
inner classes are getting invoked.

Any ideas?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org