Skip to content
Advertisement

Flyway don’t clean database correctly, and execute migration files two times

I’m using flyway for migration database, as well I use FlywayTest for my integration tests, but When I create a test using :

I get this error :

If you not :

This comes from FlywayTestExecutionListener.class but it migrate the database again.

Why flyway do this, and how can stop this.

More details

The problem is not happen when I don’t use schema names in my tables. every thing work fine.

Advertisement

Answer

If you’re reusing FlywayTestExecutionListener on every test, then the setup will be executed per every class with the @TestExecutionListeners, even if you use beforeTestClass.

In JUnit, a way to setup resources for a set of tests a single time is to define a Rule (for Unit 4) and Extensions (for JUnit 5).

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement