liveBook · Manning

Narrow integration test

As explained in .NET in Action, Second Edition

A narrow integration test is an integration test focused on a small component while exercising a real external dependency.

A narrow integration test checks a small component while exercising a real external dependency. Use it after unit tests when independently developed units must work together, but keep the scope small enough to diagnose failures. section 8.0 section 8.2

For an Entity Framework Core repository, test queries against a real SQLite database because query correctness cannot be established through a fake implementation. Set up an in-memory SQLite connection, keep it alive for the test lifetime, construct the DbContext and repository, then dispose the connection and context. section 8.2

Repository tests with SQLite

Seed comics with numbers 1, 12, and 4, call GetLatestNumberAsync, and assert 12. Separately call AddComicAsync with comic 3, retrieve it from the DbContext, and assert that it exists. These tests exercise repository behavior, EF Core queries, persistence, and the database together without activating a broad application surface.

How .NET in Action, Second Edition covers it

How deep it goes
Builds SQLite setup, lifetime management, seeding, assertions, and disposal, but does not develop broad multi-module integration coverage.
Examples
Uses ComicRepository tests for latest-number queries, comic insertion, empty results, seeded records, and an in-memory SQLite database.
What you can do after
Build it from scratch as a focused repository test fixture that seeds data, invokes asynchronous methods, asserts results, and cleans up resources.
How it connects
Connects integration testing with unit testing, mocks, fakes, Entity Framework Core, SQLite, and database persistence.

Related concepts

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