Span Integration Testing

I use Flyway to handle database migration. Everything works fine: default location of migration files:

main/resource/db/migration/V1...

I run integration tests, and my installation uses a separate database schema for integration, which I would also like to deal with span. Integration tests, however, are in the test(not main) folder . When the Flyway bean runs migrate(), it does not find the migration files because they are in the folder main. If I put the migration files in test/resource/db/migration/V1..., it will work.

I really don't need to copy this file to the resources folder test, so I don't need to support both. Is there a way to get Flyway to use the same migration files for the integration test as for a regular application?

+5
source share
2 answers

I assume you are using Maven? For unit tests test/resources, both and are loaded into the classpath main/resources. Files usually test/resourcestake precedence because they are placed higher in the classpath - if I remember correctly. Regardless, I do not recommend you to do this.

Flyway , (.. test/resources/integration/migration/) main/resources/db/migration .

Flyway , DbUnit ( , ).

+4

: Flyway, . https://github.com/flyway/flyway-test-extensions.

DbUnit , .

Adams , test/resources/db/migration/.

:

  • maven flyway-maven-plugin gradle, test/resources/integration/migration/ script.
  • test/resources/db/migration/ , V999.0.x__ simular. .
  • spring 4.x, spring -test SqlScriptsTestExecutionListner. .

:

  • reset . .
  • .
  • , . = > .
+6

Source: https://habr.com/ru/post/1609675/


All Articles