I'm writing to try and initiate a bit of a discussion regarding Spring Unit testing and in particular Transactional unit tests.
We currently have around 441 tests in a variety of classes annotated like so:
@RunWith(SpringJUnit4ClassRunner.class)
@TransactionConfiguration
@ContextConfiguration(locations={"/context/ServiceTest-context.xml"}, inheritLocations=false)
public class ServiceTests extends AbstractTransactionalJUnit4SpringContextTests {
@Test
public void testSomething() {}
@Test
public void testSomethingElse() {}
}
Each of our tests classes have their own test context.
We're facing an issue in which when we run individual test classes or individual packages the tests run fine.
However when we want to scale that up to run ALL our tests (currently > 400) by using maven or something similar such as Hudson integration.
mvn test
We get to a point and then start to experience Java GC Limit exceeded errors.
Now I get the feeling that this is down to our test plan design rather than the need for us to up any memory limits or turn off the warnings.
Can anyone share their experiences and the way they solved a similar problem?
Eggsy
I'm pretty sure that the container will hold on to all the contexts for the duration of the its lifecycle unless you explicitly call appCtx.close()
Is there some particular reason that every test has its own context? Because unless you have a special reason for doing that....I'd say, don't do that. As long as you have appropriate setup and teardown methods, you should be able to share. Even if you group similar tests together and have just those share contexts. More info please!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With