Start Learning
Javaneer
Back to the Spring path
🧪
Module 5

Testing Spring Applications

Fast, trustworthy tests at every layer.

Prove BookVault works and keep it working. The Spring test stack, fast web and data slice tests, mocking beans, real-database integration tests with Testcontainers, testing security, and a sane overall strategy.

7 Lessons in this stage1 h 44 min
Start the first lesson

Lessons in this stage

  1. 01

    The Spring Test Stack

    Intermediate

    What spring-boot-starter-test gives you, and when to load the whole context with @SpringBootTest versus a thin slice.

    14 min
  2. 02

    Web Slice Tests with @WebMvcTest

    Intermediate

    Test controllers in isolation with MockMvc - routing, validation, status codes, and JSON - without a database.

    16 min
  3. 03

    Data Slice Tests with @DataJpaTest

    Intermediate

    Test repositories and queries against a real (test) database, with the rest of the app left out.

    14 min
  4. 04

    Mocking Collaborators

    Intermediate

    Replace a bean in the context with a Mockito mock using @MockitoBean, so a slice test stays focused.

    14 min
  5. 05

    Integration Tests with Testcontainers

    Advanced

    Run tests against the real database engine in a throwaway Docker container - no more H2-vs-production drift.

    18 min
  6. 06

    Testing Secured Endpoints

    Intermediate

    Assert that your access rules actually work - authenticated, anonymous, and wrong-role requests.

    14 min
  7. 07

    Test Strategy, Data & CI

    Intermediate

    The test pyramid, choosing the right test for each job, managing test data, and running it all in CI.

    14 min

Ready to test yourself?

Take the stage assessment to check your mastery. Pass it to earn a stage badge toward your Javaneer certificate.

Take the assessment