Description
Grzegorz Borkowski opened SPR-7238 and commented
I run unit tests using Spring integration testing tools, that is, marking test classes with @ContextConfiguration
(locations = {...}) , which implies that Spring uses the same context for all test having the same context location configuration. In the tests, I call some transactional service. Transactions are weaved during compile time with AspectJ.
The problem is following: as long as there is only one Spring context created during tests (all test classes using the some context location configuration, so there is only one context created), everything runs smoothly. But when one test uses different context configuration, and there are two contexts created (which should be independent from each other), transactions don't get started, and I got exception "no transaction in progress...".
It looks like two contexts that should be independent, actually have some impact on each other. More precisely, it works this way: tests methods based on first spring contexts pass, then test methods using second context are run, and they pass, but then another test methods using first spring context are run and they fail with "No transaction" exception. So it look like running second context spoils the first one.
This is serious problem for us, which makes running tests very difficult. JUnit doesn't let us decide on the order in which test methods are run, which makes this really problematic.
I attach simple test case as maven project, run the test and see that they fail (if they are run in order: test 1, 2, 3). If you change the second test so that is uses the same context configuration like tests 1 and 3, everything works fine. But it test 2 uses different configuration, test 3 fails.
Affects: 3.0.2
Reference URL: http://forum.springsource.org/showthread.php?p=301948#post301948
Attachments:
- springtestcase.zip (17.86 kB)
Issue Links:
- TestContext framework should support one AspectJ instance per ApplicationContext [SPR-6353] #11019 TestContext framework should support one AspectJ instance per ApplicationContext ("duplicates")
1 votes, 3 watchers