-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaced @DirtiesContext with manual reset of H2 database #95
Replaced @DirtiesContext with manual reset of H2 database #95
Conversation
3aecafa
to
b951d94
Compare
|
||
override fun beforeTestMethod(testContext: TestContext) { | ||
super.beforeTestMethod(testContext) | ||
println("Cleaning up database...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this show up in the test log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I change anything or can we merge? This is an important PR @DoStini
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, it might be a bit cluttered but we can merge
b951d94
to
5263529
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Since
@DirtiesContext
logic kept bringing issues in the tests, I replaced it with a listener that automatically truncates every table from the H2 test database. Additionally, I had to deactivate an optimization on the entity manager to ensure ID consistency.Here are the 2 primary sources that inspired this implementation:
This means that the DB will be reset in EVERY single test, as opposed to only between endpoint tests like before. There was no need for an
@EndpointTest
in this implementation since it's the same as the@NestedTest
, so I removed it.Review checklist
docs/openapi.yml