Try a TestSetup decorator. the suite can try to find all testcases based on
filename. I think there is such a testrunner/suite already for the junit
project (junit-addons).
I've found the TestSetup decorator to be quite useful in a development
environment like Eclipse. Running them naively from maven using the fork is
quite painful, and should not be done. Define 1 testcase whose only purpose
is to deliver a decorated suite.
I use the following pattern for this:
public class FooTest extends TestCase {
// test methods
public static Test suite() {
return new MyTestSetup(new TestSuite(FooTest.class));
}
}
public class BarTest extends TestCase {
// testmethods
public static Test suite() {
return new MyTestSetup(new
TestSuite(BarTest.class));
}
}
public class AllTests extens TestCase {
public static Test suite() {
TestSuite result = new TestSuite();
result.add(FooTest.class);
result.add(BarTest.class);
return new MyTestSetup(result);
}
}
The last testsuite can be replaced with more elegant methods of finding and
adding testcases.
Using this pattern, it is possible to just run the FooTest cases, or run all
testcases from within your IDE.
Martijn
-----Oorspronkelijk bericht-----
Van: Micah Craig [mailto:[EMAIL PROTECTED]
Verzonden: woensdag 24 november 2004 17:29
Aan: Maven Users List
Onderwerp: Re: problem *not* forking unit tests
First, thanks for the quick reply, and a thousand apologies for the
duplicate post (more email addresses than I know what to do with.) I
appreciate that not forking is a somewhat fringe use case. The problem that
we are facing is that as a Spring based project, we face a non-negligible
initial startup cost (loading our Application Context), which, in a
non-forked environment, we can avoid repeating for each test. When forking,
the time to run all our tests balloons dramatically (hours, not minutes).
Can you provide any insight as to how we might alleviate this burden (Test
Suites seem a possible option, but we worry about maintenance overhead)?
Thanks very much,
-micah
Ryan Sonnek wrote:
>this question comes up so frequently, and the answer is always, "Junit
>tests should be forked." Can someone PLEASE change the default
>behavior of the test plugin to fork unless it's overridden? It would
>save on the constent confusion in this area.
>
>-----Original Message-----
>From: Julien Kirch [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, November 23, 2004 3:21 PM
>To: Maven Users List
>Subject: Re: problem *not* forking unit tests
>
>
>Hi Micah
>
>I think the test forking law is "thou shall fork", not forking is a
>real
>
>classpath mess between maven and project classpath (and caused your
>problem), I don't think not forking is ever a good idea.
>
>Julien
>
>
>Micah Craig wrote:
>
>
>
>>Hi,
>> I just upgraded from rc1 to 1.0.1, and suddenly, I can't run JUnit
>>tests un-forked (maven.junit.fork=no). Failure output is below.
>>
>>
>Could
>
>
>>this be some sort of mangled classpath issue left over from the
>>
>>
>upgrade,
>
>
>>or is something more sinister afoot. Thanks,
>>
>> -micah
>>
>>
>
>
>
>---------------------------------------------------------------------
>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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]