Replies: 1 comment
-
I am facing with the same Problem when I am using an Abstract class. That the @beforeeach does have probably a different context, so the Transaction is then gone. And in the test method, I do not have the database changes made in createFixtures(). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Using the latest Quarkus and Junit Jupiter I have a large set of service tests that creates test fixtures in the DB. I am using @TestTransaction to make sure that the fixtures don't persist in the DB once the tests complete.
This pattern works as expected:
however I cannot figure out how I could pull the createFixtures call in an @beforeeach method:
With the code above the fixtures persist after the tests.
I have tried moving the @TestTransaction to the class level, adding it to the @beforeeach method, nothing helps... any suggestion?
Thanks!
Franck
[Edit]: Related question: is there any simple way to check whether I am currently in the context of an @TestTransaction? What I really need to do is make sure I don't allow createFixtures() to proceed unless I know it will be rolled back...
Beta Was this translation helpful? Give feedback.
All reactions