Testing a Spring Boot REST API with Testcontainers
Table of contents
Learn how to create a Spring Boot REST API with Spring Data JPA and PostgreSQL,
then test it using Testcontainers and REST Assured.
Time to complete
25 minutes
In this guide, you will learn how to:
- Create a Spring Boot application with a REST API endpoint
- Use Spring Data JPA with PostgreSQL to store and retrieve data
- Test the REST API using Testcontainers and REST Assured
Prerequisites
- Java 17+
- Maven or Gradle
- A Docker environment supported by Testcontainers
NoteIf you're new to Testcontainers, visit the Testcontainers overview to learn more about Testcontainers and the benefits of using it.
Modules
- Create the project
Set up a Spring Boot project with Spring Data JPA, PostgreSQL, and a REST API.
- Write tests
Test the Spring Boot REST API using Testcontainers and REST Assured.
- Run tests
Run your Testcontainers-based Spring Boot integration tests and explore next steps.