aahlenst / fast-tests-spring-boot-flyway

Example that demonstrates how to make integration tests run fast with Spring Boot, Flyway, and Testcontainers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fast, Reliable Integration Tests with Spring Boot and Flyway

This sample project shows different ways to set up reliable integration tests with Spring Boot, Flyway, and Testcontainers. All other technologies used (JDBC, PostgreSQL, JUnit 5) are interchangeable: Using, for example, Hibernate, MariaDB, and TestNG is possible with the same techniques.

All approaches guarantee that all test cases are independent (start with a fresh database) and do not hide errors (like database rollbacks). Furthermore, the test classes can be executed concurrently1 to take advantage of multicore processors. What varies, however, is their execution speed and how much custom plumbing is necessary.

The performance numbers are indicative. They depend on your hardware and the specifics of your project, for example, the number of Flyway migrations.

Footnotes

  1. The project relies on Gradle's parallel test execution because it uses process isolation to run the tests concurrently. This ensures that tests that run simultaneously do not interfere with each other while keeping the number of running PostgreSQL containers at a reasonable number (one PostgreSQL container per worker process).

About

Example that demonstrates how to make integration tests run fast with Spring Boot, Flyway, and Testcontainers.

License:MIT No Attribution


Languages

Language:Java 100.0%