Introduce reactive @Transactional support in the TestContext framework
See original GitHub issueSince we have @Transactional
working with R2DBC repositories in 1.0 M2 (as said here), I would like to ask if there is a way to make @Transactional
working with JUnit (integration) tests (the same way we are able to do when using JDBC repositories). Is this currently possible? Will this even be possible? What is the right approach to achieve transactional tests ?
Currently, running a @Transactional
@SpringBootTest
gives me java.lang.IllegalStateException: Failed to retrieve PlatformTransactionManager for @Transactional test
(the same problem as this guy has: http://disq.us/p/2425ot1).
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:18 (6 by maintainers)
Top Results From Across the Web
Programmatic Transactions in the TestContext Framework
Spring has excellent support for declarative transaction management throughout application code as well as in integration tests.
Read more >Testing - Spring
See transaction management with the TestContext framework. 3.1.4. Support Classes for Integration Testing. The Spring TestContext Framework ...
Read more >Index (spring-test 5.0.5.RELEASE API) - Javadoc.io
Abstract base test class which integrates the Spring TestContext Framework with explicit ApplicationContext testing support in a JUnit environment.
Read more >Why Spring Framework is Popular - DataFlair
ii. New test execution callback methods introduced in Spring TestContext Framework using TestNG, JUnit 5 via SpringRunner. iii. XMLUnit support is upgraded to ......
Read more >What's new in Spring Framework 5?
JDK baseline update · Core framework revision · Core container updates · Functional programming with Kotlin · Reactive Programming Model · Testing ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @mp911de! I had some trouble with this lately, and since the
@Transactional
annotation is not supported yet I came out with an small helper that transform any publisher to a rollback operation:Then I can use it on tests like this:
I thought this helper can be used by the
@Transactional
annotation in some way. Maybe the annotation can find all publishers within the@Test
and add the transformer right before theStepVerifier
(if present?). I’m not sure how possible/easy that might be though 😅. Another approach I was thinking is to add this right into theStepVerifier
(again, not sure if possible since it requires Spring to work) or to another implementation of the StepVerifier (something likeTxStepVerifier
perhaps?). Of course, this approaches will not use the@Transactional
annotation, but will add more control over which publisher should rollback and which should not 🙂Hope this helps, at least as a brainstorm on some ways to solve the issue.
Cheers!!
I’m glad this helped @nhajratw 🙂
In case anyone is interested, I went one step further and created a transactional step verifier:
This makes things a little bit easier to use 😁 so based on the same example above the usage would be:
Cheers!