liveBook · Manning

Chapter 16: Implementing integration tests for Spring apps

What you will learn in chapter 16 of Spring Start Here, Second Edition

This introduction explains what Spring integration tests check and why they complement unit tests.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction explains what Spring integration tests check and why they complement unit tests.

Key terms: unit test, integration test, isolation, Spring integration test, application logic, Spring framework, unit tests, integration tests, fast feedback

16.1 Implementing Spring integration tests

This section explains what integration tests check in Spring apps, how they differ from unit tests, and when to use real dependencies or mocks.

Key terms: integration tests, persistence layer, assumptions, mock, repository, real object, in-memory database, H2, Testcontainers, infrastructure

16.2 Implementing controller integration tests

Explains why controller integration tests check an endpoint from a client’s perspective, then demonstrates a MockMvc test for a money-transfer endpoint and places it in a balanced test strategy.

Key terms: controller integration test, endpoint contract, @SpringBootTest, WebApplicationContext, MockMvc, MockMvcBuilders.webAppContextSetup(context).build(), TestRestTemplate, WebTestClient, @MockitoBean, AccountRepository

16.3 Questions

This section provides self-check questions about integration testing in Spring, with answers in Appendix A.

16.4 Summary

The section summarizes what Spring integration and controller tests validate, how they are set up, and how they fit into a balanced testing strategy.

Concepts explained in this chapter

← Chapter 15: Unit testing in Spring apps

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.