🍃 Spring Boot

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. 1.Unit Testing

    Unit tests verify a single class in isolation — no Spring context, no database, no network.

  2. 2.Integration Testing

    Integration tests verify that components work correctly together — service with database, controller with security filter, or the full application stack.

  3. 3.JUnit 5

    JUnit 5 is the default test framework in Spring Boot, included via spring-boot-starter-test.

  4. 4.Mockito

    Mockito is the mocking framework bundled with spring-boot-starter-test.

  5. 5.MockMvc

    MockMvc tests Spring MVC controllers without starting a real HTTP server.

  6. 6.TestContainers

    Testcontainers is a Java library that spins up real Docker containers during integration tests.

  7. 7.WebMvcTest

    WebMvcTest is a Spring Boot test slice that loads only the web layer — controllers, filters, advice, and MockMvc infrastructure — without starting the full application…

  8. 8.DataJpaTest

    DataJpaTest is a Spring Boot test slice that loads only the JPA layer — entities, repositories, and the EntityManager — without the web layer or service beans.

  9. 9.SpringBootTest

    SpringBootTest loads the full application context — all beans, configuration, security, web layer, and data layer — making it the closest approximation to a real running…

  10. 10.API Testing

    API testing verifies the HTTP contract of a service — status codes, response bodies, headers, error formats, and pagination.

  11. 11.Performance Testing

    Performance testing measures how a microservice behaves under load — validating response times, throughput, resource utilisation, and breaking points.

  12. 12.Security Testing

    Security testing verifies that a microservice correctly enforces authentication, authorisation, input validation, and data protection.