Skip to content

Improve thread safety in Spring JUnit integration [SPR-12421] #17028

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

  1. Improve thread safety for the SpringRunner for JUnit 4.
  2. Improve thread safety for the SpringClassRule and SpringMethodRule for JUnit 4.
  3. Improve thread safety for the SpringExtension for JUnit Jupiter (in JUnit 5).

Affects: 3.0 GA

Reference URL: http://stackoverflow.com/questions/26882936/why-does-springjunit4classrunner-not-work-with-surefire-parallel-methods

Issue Links:

3 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions