I got around this kind of issue a few years back (long before I started using Maven) by having a special test suite class that created a single test suite out of all the test classes. The grand test suite would set up the singleton, then call all the test suites for the individual classes. Each test class would also initialize the singleton in their own setup, but the initialization would do nothing if the singleton was already there. We could then run any test in isolation and it would run fine, but the Ant build process would just run the grand test suite. The only drawback was that the output would only be a single test report, which sometimes caused problems finding a test when one failed, but it was certainly better than having a lengthy setup for each individual test class.
If you'd like more details, let me know and I'll take some memory pills and try to remember how we did it. ..David.. -----Original Message----- From: Siegfried Goeschl [mailto:[EMAIL PROTECTED] Sent: Thursday, May 26, 2005 10:47 AM To: Maven Users List Subject: Re: Singletons/static variables and Unit testing Hi Bryan, I think Maven is not guilty but your approach using static initializer and singletons is improvable The JUNIT way +) of defining a lifecycle for an individual test case is setup() and tearDown() +) of providing resources shared across multiple testsuites is using a TestSetup The only trouble is that executing individual tests is not possible since they depend on running the TestSetup before Cheers, Siegfried Goeschl bryan hansen wrote: >We are using maven to run our Unit Tests which are >accessing the database through Hibernate. It seems >that when Maven builds the test suite it is >reconfiguring hibernate before each TestCase. So if >there are 3 tests in a class it will run those with >the same configuration, but when it goes to the next >test it will reconfigure hibernate again. I have the >configuration code in a static initializer and am >accessing it from a Singleton (in fact I copied it >from Hibernate's website) and it is still doing it. I >have tried setting the various properties for testing >and can't seem to make a difference: > >maven.junit.fork=true >maven.junit.jvm=java > >It has gotten to the point that the build box is >throwing out of memories errors because it is trying >to allocate so many resources. > >The only step I can think to do next is to not have >maven build my test suite and instead create on >myself, but I am afraid that it will become >unmaintainble because of all the test cases we have. > >Any ideas? > >Thanks, > >Bryan > >__________________________________________________ >Do You Yahoo!? >Tired of spam? Yahoo! Mail has the best spam protection around >http://mail.yahoo.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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
