Spring Boot Testing
12 lessons in this section of the Spring Boot tutorial. Work through them in order, or jump to the one you need.
- 1.Unit Testing
Unit tests verify a single class in isolation — no Spring context, no database, no network.
- 2.Integration Testing
Integration tests verify that components work correctly together — service with database, controller with security filter, or the full application stack.
- 3.JUnit 5
JUnit 5 is the test framework behind every Spring Boot test, pulled in by spring-boot-starter-test.
- 4.Mockito
Mockito is the mocking library bundled with spring-boot-starter-test.
- 5.MockMvc
MockMvc lets you exercise Spring MVC controllers with real request mapping, argument binding, validation, JSON conversion, exception handlers and (optionally) the Spring…
- 6.TestContainers
Testcontainers is a Java library that spins up real Docker containers during integration tests.
- 7.WebMvcTest
How to test Spring Boot controllers with @WebMvcTest and MockMvc: what the slice loads, request and response assertions, Bean Validation, exception handlers and Spring…
- 8.DataJpaTest
@DataJpaTest is a Spring Boot test slice for the persistence layer.
- 9.SpringBootTest
@SpringBootTest starts your real application context, so it can catch wiring, security, transaction, and SQL problems that slice tests and unit tests cannot.
- 10.API Testing
API testing verifies the HTTP contract of a service — status codes, response bodies, headers, error formats, and pagination.
- 11.Performance Testing
Performance testing measures how a microservice behaves under load — validating response times, throughput, resource utilisation, and breaking points.
- 12.Security Testing
Security testing verifies that a microservice correctly enforces authentication, authorisation, input validation, and data protection.