liveBook · Manning

Integration test

As explained in Functional Design and Architecture: Examples in Haskell

An integration test verifies that multiple software components work together correctly in an environment representing their actual integration conditions.

Components can work separately and still fail where they meet. An integration test checks functional requirements across connected application parts, especially the edges between subsystems. It runs with real subsystems and services in conditions resembling production, so it can reveal behavior that an isolated functional test misses. section 15.1 section 15.1.4

That realism has a cost: integration tests can be slow, unreliable, and difficult to set up. They also cannot easily trigger a precisely timed database outage. Use mocking and dependency injection when a test needs controlled subsystem failures; use integration tests to check that the real parts work together. section 15.1.4 section 15.2.1

Test a scenario through its real interpreter

A labyrinth-generation test runs a scenario through a real runtime, then checks its bounds and the allowed ranges for wormholes and exits. The assertions check the result of integrated execution rather than replacing the interpreter with a test double. section 15.1.4

A database-backed scenario needs another safeguard. Hard-coding a production RocksDB path makes a test potentially harmful: an unproven loader could corrupt data or breach security. Pass the database configuration into the scenario instead, and run the test against a specially prepared test database. section 15.1.4

Listing 15.7 Scenario for loading a labyrinth from the KV database
loadLabyrinth :: Int -> LangL Labyrinth
loadLabyrinth labIdx = 
  withKVDB' kvDBConfig $ do
    labVal :: LabVal <- loadEntity (LabKey labIdx)     #1
    pure (fromLabVal labVal)
  
kvDBConfig :: KVDBConfig LabKVDB
kvDBConfig = RocksDBConfig "./prod/labyrinths"

The listing makes the unsafe coupling visible: the loading scenario selects a production database path internally. section 15.1.4

Integration tests also provide early feedback while an application is incomplete. A minimum viable product can connect enough subsystems to test an idea and remain a foundation for further development. Passing integration tests supports confidence that those connected parts function together, provided the tests cover the relevant requirements. section 3.1.1 section 15.1.4

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Works through real-interpreter and database-backed tests, including configuration isolation; leaves controlled failure scenarios to mocking.
Examples
Tests labyrinth generation through a real runtime and loads a labyrinth from a separately configured RocksDB test database.
What it assumes
Assumes familiarity with Haskell scenarios, interpreters, and database configuration in the worked examples.
What you can do after
Apply it via a real interpreter and a configured RocksDB test database to check integrated behavior without targeting production data.
How it connects
Connects functional testing, minimum viable products, interpreters, dependency injection, and mocking.

Also explained in

Compare how 33 books explain integration test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Design and Architecture: Examples in Haskell. The section links point to the parts of the book it draws on.