@TestTransaction in combination with Junit5 @Nested does not roll back

See original GitHub issue

Describe the bug

In a @QuarkusTest placing @TestTransaction on methods inside a Junit5 @Nested class does not roll back the transaction - the test data stays in the database. Moving the test method out of the @Nested class makes it work.

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.0.2.Final and latest

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mkoubacommented, Jul 7, 2022

Well, non-static nested classes (i.e. inner classes) just to be precise… static nested classes are just fine 😉

0reactions
manovotncommented, Jul 5, 2022

Yeah that’s still the case. Nested classes are not managed beans as per spec https://jakarta.ee/specifications/cdi/2.0/cdi-spec-2.0.html#what_classes_are_beans

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transaction roll back is not working in test case in @Nested ...
Rollback ; import org.springframework.transaction.annotation.Transactional; // JUnit5 @SpringBootTest public class TestClass { @Resource ...
Read more >
Transaction roll back is not working in test case in @Nested ...
when use spring-boot, JUnit5 and Mybatis, Rollback of test case in nested class is not working. @SpringJUnitJupiterConfig(classes ...
Read more >
Testing - Spring
You may not need this section of the testing chapter to help you ... By default, the framework creates and rolls back a...
Read more >
Automatic Rollback of Transactions in Spring Tests
What Does @Transactional Do? Beware: Only Test-Managed Transactions Are Rolled Back; Set Up or Tear Down Outside of a Transaction; Spring Boot ...
Read more >
JUnit 5 Tutorial: Writing Nested Tests - Petri Kainulainen
By default, a nested test class can contain test methods, one @BeforeEach method, and one @AfterEach method. Because Java doesn't allow static ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found