liveBook · Manning

Integration test

As explained in Shipping Go: Develop, deliver, discuss, design, and go again

Integration testing verifies functionality between units of software, often including interactions with external dependencies.

An integration test checks whether units of software work together, often across an external dependency such as a database. It sits above fast, isolated unit tests and below broader end-to-end tests, so it provides useful system feedback without making the entire test suite expensive or unpredictable. section 3.4

Use integration tests to:

  • Verify interactions that simulated external integrations cannot validate. section 9.1
  • Check the user experience across connected components rather than only one module. section 9.1
  • Run broader tests after unit tests pass, keeping failures easier to isolate. section 3.4

Moving translations from a client to a database

A translation service can retain its existing interface while configuration selects an external client, a database, or a hybrid fallback. First test the existing behavior, then connect the database and add integration tests that verify the resulting user experience and feature requirements. section 9.0 section 9.1

Figure 3.2 End-to-end tests are smaller at the top because they are more expensive and not as dependable. They should be supported by larger suites of integration and unit tests. Each layer should run on its own. Start with unit tests and progress up the pyramid in different phases.

Use the testing pyramid to place integration tests between larger unit-test suites and smaller, more expensive end-to-end suites. section 3.4

Listing 9.1 core.go
type Configuration struct {
    Port            string `json:"port"`
    DefaultLanguage string `json:"default_language"`
    LegacyEndpoint  string `json:"legacy_endpoint"`
    DatabaseURL     string `json:"database_url"`      #1
    DatabasePort    string `json:"database_port"`     #2
}

Inspect the configuration fields that enable a database connection while preserving the option to use the legacy endpoint. section 9.1

How Shipping Go: Develop, deliver, discuss, design, and go again covers it

How deep it goes
Explains placement, cost, reliability, and a database migration workflow, but stops short of detailed test code.
Examples
Uses a translation-service migration involving a legacy client, database connection, configuration, and hybrid fallback.
What it assumes
Assumes basic unit-testing experience and teaches when to replace simulated integrations with tests of real interactions.
What you can do after
Build integration checks that validate existing behavior and user experience across an application and database.
How it connects
Connects unit testing, end-to-end testing, databases, dependency injection, configuration management, and external services.

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 Shipping Go: Develop, deliver, discuss, design, and go again. The section links point to the parts of the book it draws on.