Jörg answered my question, surefire doesnt support TestSuites but you can still run them the way I did (even though it's not pretty).
Bashar -----Original Message----- From: diroussel [mailto:[EMAIL PROTECTED] Sent: Thursday, February 01, 2007 2:42 AM To: [email protected] Subject: Re: Maven 2 surefire doesn't handle junit TestSetup very well You don't say what doesn't work when you run if from maven? Is it that the tests don't run at all? Or that the setup gets called too many times? Could it be to do with forking the JVM for each test? Your testSuite() method looks stange to me, surely it should return something to the test runner, who or what is supposed to call it? David Bashar Abdul Jawad wrote: > > Hello, > > > > I am using junit TestSetup to set up a common selenium connection among my > different tests. The TestSetup runs a global setup and Teardown once > before > any of the tests are run. I wrapped a TestSuite in a subclass of TestSetup > and it works perfectly fine when the TestSuite is run from eclipse: > > > > The code for my TestSuite: > > > > public class AllTestsOneTimeSetup { > > > > public static Test suite() { > > TestSuite suite = new TestSuite(); > > suite.addTestSuite(SomeTest.class); > > TestSetup wrapper = new TestSetup(suite) { > > protected void setUp() { > > oneTimeSetUp(); > > } > > > > protected void tearDown() { > > oneTimeTearDown(); > > } > > }; > > > > return wrapper; > > } > > } > > > > Now to make this suite runs in Maven 2 I had to add the following method > to > the TestSuite: > > > > public void testSuite(){ > > TestSetup test = (TestSetup) AllTestsOneTimeSetup.suite(); > > TestResult result = new TestResult(); > > test.run(result); > > } > > > > Now something weird happens. The global setup an tear down run fine and > Maven 2 runs all the tests in the suite fine but It always reports that > it > is running 1 test (the testSuite test) and that it was successful (as the > testSuite itself doesn't fail, the included tests do). > > > > One way around this is to do the following: > > > > if (!result.wasSuccessful()){ > > String message = ""; > > for (Enumeration e = result.failures(); e.hasMoreElements() > ;){ > > message += e.nextElement() + "\n"; > > } > > for (Enumeration e = result.errors(); e.hasMoreElements() ;){ > > message += e.nextElement() + "\n"; > > } > > Assert.fail(message); > > result.endTest(test); > > } > > > > My question is, does anyone have a cleaner solution to this? > > > > Thanks, > > > > > > > > > > > Bashar > > > > > -- View this message in context: http://www.nabble.com/Maven-2-surefire-doesn%27t-handle-junit-TestSetup-very -well-tf3078018s177.html#a8745415 Sent from the Maven - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
