-
Notifications
You must be signed in to change notification settings - Fork 35
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
@FlywayTest not working on abstract classes? #57
Comments
Hi Stefan, currently it was never a planned to use But a work around could be following in your abstract class: @BeforeClass
@FlywayTest
public static void beforeClass() {} I have never tried it, but together with Florian |
@FlorianGWE Alright. Thank you for the hint. I will try this once I am back on it :) |
I have the same problem. I noticed that if I use the deprecated FlywayTestExecutionListener from org.flywaydb.test.junit.FlywayTestExecutionListener, i can use FlywayTest on abstract classes. |
On a similar note, what you probably want is a clean slate before each test, not only each test class. @SpringBootTest(classes = {FooApplication.class})
@TestExecutionListeners(FlywayTestExecutionListener.class)
abstract class BaseSpringTest {
@BeforeEach
@FlywayTest
void flywayClean() {
}
} in general when testing using The second any test modifies state you have no reasonable way of knowing when it will be executed, except by isolating it in its own class. If a modification of any related state concerning your test does not cause your test to fail, you should think (and probably hard) about if either your state or your test is well defined. |
So I am having this abstract class to make life easier with unit tests:
Notice the
@FlywayTest
annotation. This does not seem to work. I have to add@FlywayTest
to all test classes separately e.g.otherwise it won't work. I do not know if this is expected or even intended but I thought I raise that issue here in case it isn't.
I am using
org.flywaydb:flyway-core
andorg.flywaydb.flyway-test-extensions:flyway-spring-test
in a Spring Boot (2.0.1.RELEASE) application.The text was updated successfully, but these errors were encountered: