liveBook · Manning

Integration test

As explained in Spring in Action, Sixth Edition

An integration test verifies the interaction of multiple application components, often in a running application context with real dependencies.

An integration test verifies that multiple application components work together. Instead of replacing every dependency with a mock, it can exercise a running application, real framework infrastructure, and persistence components. section 12.3.3 section 13.1.3

A practical integration test typically follows one of these arrangements:

  • Start Spring Boot with @SpringBootTest(webEnvironment = RANDOM_PORT), inject WebTestClient, and send requests to the running server. section 12.3.3
  • Let Spring create the controller and inject a real repository, then assert the API response with JSONPath expressions. section 12.3.3
  • Use @DataR2dbcTest to create an application context containing Spring Data R2DBC repositories, then verify reactive results with StepVerifier. section 13.1.3

Testing a live reactive endpoint

A test can request /api/tacos?recent, expect an HTTP 200 response and JSON array, then verify that the array contains three named tacos: Carnivore, Bovine Bounty, and Veg-Out. The injected WebTestClient already knows the randomly assigned server port. section 12.3.3

How Spring in Action, Sixth Edition covers it

How deep it goes
Demonstrates live-server and repository test setup, assertions, and reactive verification, but does not detail broader test strategy.
Examples
Uses a live taco endpoint test and an IngredientRepository test covering deletion, insertion, retrieval, and expected reactive values.
What it assumes
Assumes Spring WebFlux, Spring Boot testing, reactive types, and repositories; teaches the relevant annotations and test flow through examples.
What you can do after
Builds integration tests with Spring Boot, WebTestClient, @DataR2dbcTest, and StepVerifier.
How it connects
Connects Spring Boot testing, WebTestClient, WebFlux, Spring Data R2DBC, repositories, JSONPath, and StepVerifier.

Also explained in

Compare how 31 books explain integration test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.