- Java 11+
- Spring Boot
- Spring Data JPA
- MySQL
- Lombok
- JUnit 5 Framework
- IntelliJ IDEA
- Testcontainers
- Docker
- Maven
As the name suggests, integration tests focus on integrating different layers of the application. That also means no mocking is involved.
Basically, we write integration tests for testing a feature that may involve interaction with multiple components.
Examples: Integration testing of complete Employee Management Feature ( EmployeeRepository, EmployeeService, EmployeeController).
Integration testing of complete User Management Feature (UserController, UserService, and UserRepository).
Integration testing of complete Login Feature (LoginRespository, LoginController, Login Service), etc
Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
Using Testcontainers is fairly easy and it gives us the opportunity to create integration tests without the need for pre-installed components.
Using Testcontainers, we would always start with a clean database and our integration tests could run on any machine.
Testcontainer allows us to use Docker containers within our tests. As a result, we can write self-contained integration tests that depend on external resources.
- Clone this repository:
git clone https://github.com/hendisantika/springboot-testcontainers-demo.git
- Navigate to the folder:
cd springboot-testcontainers-demo
- Run the integration test:
mvn clean test