You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Spring's SpringJUnit4ClassRunner to run unit-tests (the default runner for Spring's test base-classes) there is a execution order difference compared to default JUnit 4.
In the normal JUnit test runner (BlockJUnit4ClassRunner) it executes any @Rule's before running the @Before methods in a (base-)class. Spring's test runner first executes any @Before annotated methods before processing the @Rule's.
For example this causes a TestName JUnit rule (used to get the name of the currently executing test method) to be null in a @Before method.
The current SpringJUnit4ClassRunner fails on JUnit's own test suite because of this.
Attached is a patch with a fix (changes order of @Rule execution).
Dries Schulten opened SPR-7705 and commented
When using Spring's SpringJUnit4ClassRunner to run unit-tests (the default runner for Spring's test base-classes) there is a execution order difference compared to default JUnit 4.
In the normal JUnit test runner (BlockJUnit4ClassRunner) it executes any
@Rule
's before running the@Before
methods in a (base-)class. Spring's test runner first executes any@Before
annotated methods before processing the@Rule
's.For example this causes a TestName JUnit rule (used to get the name of the currently executing test method) to be null in a
@Before
method.The current SpringJUnit4ClassRunner fails on JUnit's own test suite because of this.
Attached is a patch with a fix (changes order of
@Rule
execution).Affects: 3.0.5
Attachments:
Issue Links:
@Rule
executes outside of transaction when using the TransactionalTestExecutionListenerReferenced from: commits b109a07
0 votes, 5 watchers
The text was updated successfully, but these errors were encountered: