Closed
Description
Bastian Voigt opened SPR-12421 and commented
Status Quo
When using the maven surefire setting parallel=methods
, JUnit still creates only one runner instance per test class, i.e. one runner instance is used by multiple threads in parallel.
SpringJUnit4ClassRunner
uses a single TestContextManager
which stores the current TestContext
in an instance field.
Proposal
SpringJUnit4ClassRunner
should use a ThreadLocal
instead of a single TestContextManager
instance field.
Deliverables
- Improve thread safety for the
SpringRunner
for JUnit 4. - Improve thread safety for the
SpringClassRule
andSpringMethodRule
for JUnit 4. - Improve thread safety for the
SpringExtension
for JUnit Jupiter (in JUnit 5).- Partially addressed in JUnit Jupiter in ExtensionContext.Store is not thread-safe junit-team/junit5#478
Affects: 3.0 GA
Reference URL: http://stackoverflow.com/questions/26882936/why-does-springjunit4classrunner-not-work-with-surefire-parallel-methods
Issue Links:
- Allow for concurrent test execution in the TestContext framework [SPR-5863] #10532 Allow for concurrent test execution in the TestContext framework ("duplicates")
3 votes, 5 watchers