-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Milestone
Description
Overview
We use JUnit Jupiter 5.3.1 in our web project, the assertTimeoutPreemptively()
method will break the transaction rollback in spring's testing framework. As we use DataSourceTransactionManager
as the main transaction manager, the manager will propagate the transaction in the same thread, not across threads. The assertTimeoutPreemptively()
method starts a new thread running our code which differs from the main test thread resulting in transaction propagation breakage.
Steps to reproduce
- run test code surround by
assertTimeoutPreemptively()
- the test code request a URI in Spring's mocked web environment
- the URI insert a record to database
- the record is not rolled back
Context
- 5.3.1 (Jupiter/Vintage/Platform):
- Intellij
Possible resolution
Run test code in main test thread and run timeout in spawned thread.
Related Issues
Deliverables
- Add note regarding the use of
assertTimeoutPreemptively()
and the effects onThreadLocal
storage (in general) and with Spring's transaction management (as an example) in ...- Javadoc
- User Guide