liveBook · Manning

Integration test

As explained in Vibe Engineering

An integration test evaluates interactions between multiple software components or with external infrastructure rather than isolating a single unit.

A component can pass its unit tests and still fail when it meets an API, database, or rendering layer. An integration test checks observable behavior across components or external infrastructure, catching problems such as serialization errors, database encoding issues, and double-escaped HTML. section 8.5.3

Unit tests isolate components; contract tests check service boundaries; integration tests check components working together. End-to-end tests can go further by driving a real browser through a user journey. Outcome-focused integration tests can remain useful when an implementation changes, although they do not replace tests of individual components. section 8.5.3

Listing 8.18 Integration test: content pipeline end-to-end
def test_content_pipeline():
 
    response = client.post('/content', json={
        'body': '# Hello **world**'
    })  # User submits markdown via API
    assert response.status_code == 200
    
    content = db.query(Content).filter_by(id=response.json['id']).first()     # Content is stored in database
    assert content.body == '# Hello **world**'
    
    page = client.get(f'/content/{content.id}')
    assert '<h1>Hello <strong>world</strong></h1>' in page.text    # Rendered page contains expected HTML

This content-pipeline test submits Markdown through an API, checks the stored content, and verifies the rendered HTML. section 8.5.3

Use integration tests as part of a verification workflow:

  • Before a migration, identify missing coverage across layers and run the tests. Review AI-generated tests for validity, design, and false positives as well as reviewing the generated application code. section 2.4.1 section 2.4
  • During a framework migration, inspect tests for coupling to the old framework or persistence technology. Migrate them to the new stack; remove a test only when its coverage is duplicated or otherwise unnecessary. section 2.4.2
  • Before merging, run integration tests for affected components. Scale verification effort to system criticality and integration risk rather than treating every change as equally costly to verify. section 8.8.4 section 8.8.2

Automate the infrastructure

A member-registration integration test starts a Spring application on a random port and uses Testcontainers to provision MongoDB. This removes the manual database startup step from the test workflow, but requires Docker. If the tests fail, check Docker availability, logs, disk space, and port conflicts. section 2.10.2

Cursor
RemoteMemberRegistrationIT.java
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Testcontainers
class RemoteMemberRegistrationIT {
 
    private static final Logger log = Logger.getLogger(RemoteMemberRegistrationIT.class.getName());
    private final ObjectMapper objectMapper = new ObjectMapper();
 
    @Container
    static MongoDBContainer mongoDBContainer = new MongoDBContainer("mongo:7.0");
 
    @LocalServerPort
    private int port;
 
    @DynamicPropertySource
    static void configureProperties(DynamicPropertyRegistry registry) {
        registry.add("spring.data.mongodb.uri", mongoDBContainer::getReplicaSetUrl);
    }
 
    private URI getHttpEndpoint() {
        try {
            return new URI("http://localhost:" + port + "/kitchensink/rest/members");
        } catch (Exception ex) {
            throw new RuntimeException("Invalid URI", ex);
        }
    }
// rest of the class omitted
}
 

The listing shows the random-port application, MongoDB container, and dynamically configured database URI. section 2.10.2

Test a nondeterministic service

An integration test for a SQL-generation service calls the OpenAI API using a test profile and an API key. Rather than asserting an exact query, it checks that the response is successful and the SQL is nonempty and contains SELECT. These checks exercise the integration but do not establish that the generated query is correct. section 6.2.1

How Vibe Engineering covers it

How deep it goes
Explains cross-component assertions, infrastructure setup, migration coupling, and review of generated tests.
Examples
Demonstrates a Markdown content pipeline, a containerized MongoDB registration test, and an OpenAI SQL-generation test.
What you can do after
Apply integration testing through Spring Boot and Testcontainers, or through API, database, and rendering assertions.
How it connects
Connects integration tests with unit tests, contract tests, end-to-end tests, and continuous integration.

Also explained in

Compare how 40 books explain integration test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.