WORKINGCHAPTER 09

Integration tests with a real database

A dict can pretend to be your repository. It cannot pretend to be your constraints, your transactions or your SQL, and those are where the order bugs live.

50 MINSOFTWARE TESTING AND QUALITYUPDATED 2026-11-23
PREDICT

Ojaline's 300 tests use a DictOrders repository that raises DuplicateKey if an order with the same idempotency key is saved twice. A migration then recreates the orders index without UNIQUE. Which statement is true?

What this chapter means by integration

An integration test runs your code together with a real piece of the world it depends on and checks that they work as one. The word is stretched in the wild, so fix it for this chapter: your code plus a real dependency that you own and can start in milliseconds. For the checkout service that is the database, a SQLite file. Not the payment provider (a stranger’s service, and the topic of API and contract tests) and not a browser.

The previous chapter, Fakes, stubs and mocks, ended on a rule of thumb: if the real thing is cheap, fast and deterministic, use it. A SQLite file is all three. So the question for a database is not “which double?” It is “why would I double it at all?” You double the database when the test does not care about it. You use the real one when the test is about what the database does.

Where this layer sits in a whole suite, and how many of these tests to write against how many unit tests, is the job of the next chapter in the module, The shape of a suite. Here you learn to write one well.

What a database knows that your test does not

Your code states a request: save this order, take two units of stock. The database holds rules that decide whether that request is allowed and what is left afterwards. Four kinds matter, and a dict-based fake loses all four.

The database’s rule Example in checkout/db.py What a dict does instead
Constraints CHECK (price_kobo > 0), NOT NULL, PRIMARY KEY Accepts anything unless its author wrote the same check
Atomicity with conn: commits on success and rolls back on an exception Keeps whatever was assigned before the error
Your SQL UPDATE stock SET on_hand = on_hand - ? WHERE product_id = ? AND on_hand >= ? Runs a Python re-implementation of what you meant
Types and ordering ORDER BY id, a column declared INTEGER Python’s types and dict order

The third row is the sharpest. The line AND on_hand >= ? is what stops two buyers taking the last unit; it is the whole stock-safety story in one clause. A fake of take_stock that says if stock < qty: return False is a different program. A test of the fake proves that the fake works.

SQLite adds two honest warnings about itself. It is loosely typed: a column declared INTEGER accepts the text 'abc' and stores it as text (try insert into p(n) values ('abc') in a scratch table and read typeof(n), as the author did on SQLite 3.51.0). And its foreign keys are off unless each connection runs PRAGMA foreign_keys = ON; the SQLite documentation says they are disabled by default for backwards compatibility. In the lab’s schema order_lines has no foreign key to begin with. So a test that passes on SQLite does not prove production, if production runs another engine. We return to that below.

A fresh file per test

The rule that keeps these tests trustworthy is simple: every test builds its own database from the schema and throws it away. The lab’s db fixture in tests/conftest.py does it:

@pytest.fixture
def db(tmp_path):
    database = Database(str(tmp_path / "test.sqlite"))
    database.seed()
    return database

tmp_path is pytest’s built-in fixture: a directory unique to each test function. The pytest documentation also says it keeps the temporary directories of the last three runs, so a failed test’s file is still on disk to open with the sqlite3 shell. A new file means a new schema, four seed products and no leftovers. Twelve tests that each do this run in about half a second in the lab, because creating a SQLite file is a few milliseconds of work. There is no excuse for sharing one.

Sharing breaks tests in a specific way. The result of a test then depends on which tests ran before it and which are running beside it. That is the failure the Order-dependent tests lesson, linked here, shows, and the last step of this lab makes it happen on purpose. A suite run in random order (pytest-randomly is on in the lab) or in parallel (pytest -n auto) turns a shared file into failures that vanish when you run one test alone.

Why not :memory:? It looks faster and cleaner. In this lab it does not work, and the reason is instructive. Database opens a new short connection in every method. Each connection to :memory: is a separate empty database, so the schema created in __init__ is invisible to seed(). The first lab step shows the error. A shared-memory URI would fix that, but you would be changing how the code connects in order to suit the test. Prefer a file in tmp_path: it is the same kind of thing production uses, so there is nothing to explain.

Three behaviours that need the real thing

Take the three that the order platform team should have had, and see what each one says.

Reserve and release stock. reserve_all takes every line or none. If the second line is short, it puts back the first. The test sets up a cart with ten units of Ankara fabric (plenty in stock) and six Aso-oke caps (five in stock), expects OutOfStock, and then checks both counts are back where they began. It reads the stock from the database after the failure, which is the only honest place to read it.

A write that must roll back. save_order inserts the order, then its lines, inside one with conn: block. If a line cannot be written, the order row must not stay behind: an order with no lines is a customer who was charged for nothing. The test feeds save_order a line that is missing unit_price_kobo. The code raises KeyError after the order row is already written, and the test asserts that count_orders() is zero. That works because sqlite3 rolls back a connection used as a context manager when the block raises. You can see the test earn its place in the lab by turning autocommit on: the order row stays, and the test fails.

A duplicate idempotency key. An idempotency key says “this request is the same one I sent before”. Ojaline’s checkout sends one on every order, and the provider uses it to charge a card once. (The Payments course covers the contract in Idempotency and exactly-once.) Inside checkout, the key has a second job: two orders must never exist for one key. A test for that has two layers, and they say different things.

  • Through place_order: a replay with the same key returns the first order, created is False, the provider is charged once and one row exists. This passes on the clean code, because place_order looks the key up first.
  • At the database: saving a second order with the same key must raise sqlite3.IntegrityError, because the database should refuse it even if the application’s look-up is bypassed.

Run the second one. It fails with DID NOT RAISE. That is a finding, not a mistake in the test. In the lab’s schema orders_key is CREATE INDEX ... ON orders (idempotency_key), a plain index, so two rows with one key are legal. The application’s look-up is the only guard. A dict fake would have hidden this from you whichever way it was written: if it enforced the key, you would believe the database did too; if it did not, you would never write the test. The real file told you in 0.2 seconds.

What do you do with a test that finds a real gap? You do not delete it and you do not leave it red. You record the gap where everyone sees it: @pytest.mark.xfail(strict=True, reason=...). The test then runs on every build, shows as XFAIL in the summary with its reason, and turns into a failure the moment someone fixes the schema, which tells them to remove the marker. You also write the positive twin: a fixture that adds CREATE UNIQUE INDEX to the test’s own file and shows the constraint firing with the message UNIQUE constraint failed: orders.idempotency_key. That proves your test can pass, so the xfail is about the schema and not about a typo.

The fix itself touches the schema, the migrations and the concurrency story (two requests that arrive together both pass the look-up). That is for the later chapter on testing time, randomness and concurrency, and the lab leaves the schema alone.

Rollback and compensation are not the same thing

The word “rollback” is used loosely, and a test that mixes the two senses misses a bug. Read place_order again:

reserve_all(db, lines)          # commits: stock is taken
paid = False
try:
    charge = payments.charge(...)   # a network call
    ...
finally:
    if not paid:
        release_all(db, lines)      # a new write that undoes the reserve
order = db.save_order(...)          # a new transaction

There is no transaction around these three steps. Each database call commits by itself. When the charge fails, release_all is a compensation: ordinary code that performs the opposite write. When save_order fails halfway, the rollback is done by the database for that one transaction. The two need different tests.

  • A compensation test makes the provider fail (a decline, or an exception for an outage) and asserts the state afterwards: stock back at 100, no order. The lab’s starter suite covers the decline; the lab adds the outage, where PaymentUnavailable leaves through the finally.
  • A rollback test makes the write fail in the middle and asserts that nothing from it remains.

Neither test can see a crash between reserve_all and release_all: the process dies, the stock stays taken, and no exception ever runs the cleanup. An integration test that raises exceptions cannot simulate that, and the gap is honest to name. It is one reason real systems add a reservation expiry or reconcile stock with orders, and a test for that is a different kind of test.

What the dict fake catches, and what it cannot

Now the comparison the Why promised. In the lab you write a DictDatabase with the same methods as Database and run three behaviours against both through a fixture with params=["sqlite", "dict"]. On the clean code the result is five green and one red:

Test Real file Dict fake
A shortfall puts back the lines already taken pass pass
A replayed key writes one order pass pass
A failed line insert leaves no order pass fail

The red one is a different kind of lie from the one in Fakes, stubs and mocks. The dict is not hiding a bug here; it is less safe than the real thing. It stores the order, then fails while building the lines, and the order stays in the dict. You can repair the fake (build the lines first, then assign), but look at what you have done: you have written transaction handling by hand, in a test helper, and the next missing rule needs another repair. A fake has the rules its author remembered.

The second half of the comparison is the one that matters. Now damage the real code. In Database.take_stock, delete AND on_hand >= ? so stock can go negative. Run the tests again and the result is:

  • the real-file shortfall tests fail (DID NOT RAISE OutOfStock), twice, once in each file;
  • the [dict] shortfall test stays green.

The dict version tests the dict’s copy of the stock rule, and the copy is fine. That is the precise sense in which a fake cannot catch a bug: it was never connected to the line that broke. Keep fakes for the tests that are about something else (the pricing in place_order, say) and use the real file for the tests whose subject is storage.

When the test database is not your production database

A SQLite file is the right test database for a SQLite service. Ojaline’s real order store could run on another engine, and then the same tests on SQLite prove less. Three differences bite: SQLite’s loose typing accepts values a stricter engine rejects; its locking model (one writer at a time for the whole database) hides ordering problems that a row-locking engine exposes; and the SQL dialect differs, so a query can be valid in one and a syntax error in the other.

There are two honest answers. Run the same tests against the production engine: start a throwaway instance for the test run (a container is the usual way) and give each test its own schema or database. This costs seconds at start-up and some setup, and removes the whole class of “worked on the other engine”. Or keep SQLite for the fast layer and add a small set of tests against the production engine in CI. Either way, the habit does not change: real engine, fresh state per test, assert on what the database holds afterwards.

The SQLite project is an instructive extreme. Its own page on how it is tested describes four independent test harnesses, fuzzing, simulated crashes and I/O errors, and a goal of full branch coverage, because a database is the thing everyone else’s tests assume is right. You will not test your service that hard. You can borrow the attitude: test the failure paths, because that is where data is lost.

Concurrency, briefly

Everything above runs one connection at a time. The interesting database bugs often need two. Two sessions each read a count of 10, each write 9, and a sale vanishes. The ATLAS lessons Isolation levels and Lost update show the mechanism in a simulation, and the Databases course covers it in Transactions and ACID from the outside and Isolation anomalies. The lab’s clean take_stock avoids the lost update by making the check and the write one UPDATE. Proving that under two threads is the work of the concurrency chapter later in the course; here, make sure the single-threaded tests are exact.

Writing one well

An integration test reads best when it has the same three parts as any test (see What a good test looks like), with a database-shaped twist on each.

Arrange through the front door where you can. Use the repository’s own methods (add_product, set_stock, save_order) to put rows in, so the test also exercises the write path and does not depend on SQL you copied from the schema. Reach for raw SQL only when you need a state the code cannot produce, such as a table without its unique index. The keyed_db fixture in the lab does exactly that, and its docstring says why.

Act once. One call to place_order or reserve_all, then look. A test that places three orders and asserts on the third has hidden the first two behind a name that says nothing.

Assert on what the database holds, not on what the code returned. place_order returns an order dictionary; a test that checks only that dictionary would pass even if the row never reached the file. Read count_orders(), stock_of() and find_order_by_key() afterwards. These are the questions a support engineer would ask, and they are the questions the dict could not answer truthfully.

Name the rule, not the method. test_the_database_refuses_a_second_order_with_the_same_key tells a reader at two in the morning what broke. test_save_order_2 does not.

Keep the layer small and exact. Integration tests are slower than unit tests (here a few milliseconds each, against microseconds) and they fail for more reasons. Write one for each rule the database owns and each failure path that must leave no trace. Do not re-test pricing through the database: checkout/pricing.py is pure, and its tests belong in the unit layer, where a failure points at one function. A good ratio is many unit tests of logic and a handful of integration tests of storage, and the next chapter in the module, The shape of a suite, takes the question of how many further.

Where this goes wrong

  • A test that shares state. One database file, a module-level fixture, a table that is never emptied. Symptom: passes alone, fails in the suite, fails differently each run.
  • Seeding too much. A fixture that loads 5,000 rows makes every test slow and hides which row matters. Create the rows the test needs, in the test or a named helper.
  • Asserting on the SQL. assert "UPDATE stock" in last_query tests the spelling. Assert on what the database holds afterwards.
  • Reading back through the code under test. place_order then find_order_by_key uses the same code to write and read, so a bug in both cancels. At least once, check with the sqlite3 module directly or with a second method.
  • Calling a test an integration test while it mocks the database. If the database is a Mock, the test is a unit test of the call sequence. It cannot find a constraint.
  • Treating a pass on SQLite as a pass on production. See the section on a test database that is not your production one.
LAB Tests that read the database ~45 MIN
YOU NEEDPython 3.9+ with the lab set up (README, 'Set up')labs/testing with .venv createdno servers, and nothing is written to data/

You will write integration tests against a real SQLite file, find that the database does not enforce the idempotency key, mark the gap, and compare the real file with a dict fake. Work from labs/testing. The db fixture uses a temporary file for every test, so nothing here touches data/.

cd labs/testing
.venv/bin/pytest tests/integration/test_place_order.py -v -p no:randomly
2 passed: test_place_order_writes_the_order_and_takes_stock and test_declined_payment_puts_the_stock_back. These are the integration tests the starter suite already has: a real sqlite file, a stubbed provider.

1. See why :memory: does not work here.

.venv/bin/python - <<'EOF'
from checkout.db import Database
d = Database(":memory:")
try:
    d.seed()
except Exception as e:
    print(type(e).__name__, e)
EOF
OperationalError no such table: products. The constructor made the schema on one connection; seed() opened another, and each :memory: connection is a new empty database. This is why the lab fixture uses a file in tmp_path.

2. Reserve, release and a shortfall.

Create tests/integration/test_database.py:

"""Integration tests: checkout code against a real sqlite file (the db fixture)."""

import sqlite3
from contextlib import closing

import pytest

from checkout.inventory import OutOfStock, release_all, reserve_all
from checkout.orders import place_order
from checkout.payments_client import PaymentUnavailable


def test_reserve_takes_stock_and_release_puts_it_back(db):
    lines = [{"product_id": 3, "qty": 2}]  # the Aso-oke cap: 5 in stock
    reserve_all(db, lines)
    assert db.stock_of(3) == 3
    release_all(db, lines)
    assert db.stock_of(3) == 5


def test_a_shortfall_on_one_line_puts_back_the_lines_already_taken(db):
    lines = [{"product_id": 2, "qty": 10}, {"product_id": 3, "qty": 6}]  # only 5 caps
    with pytest.raises(OutOfStock):
        reserve_all(db, lines)
    assert db.stock_of(2) == 100
    assert db.stock_of(3) == 5


def test_a_replayed_key_returns_the_first_order_and_writes_one_row(db, payments, clock):
    items = [{"product_id": 2, "qty": 1}]
    first, created_first = place_order(db, payments, clock, items, "key-1")
    again, created_again = place_order(db, payments, clock, items, "key-1")
    assert (created_first, created_again) == (True, False)
    assert again["id"] == first["id"]
    assert db.count_orders() == 1
    assert len(payments.calls) == 1
.venv/bin/pytest tests/integration/test_database.py -v -p no:randomly
Three tests, all PASSED: 3 passed. Each ran on its own fresh file; the shortfall test checks both product counts after the failure. The imports of sqlite3, closing and PaymentUnavailable are for the next steps.

3. Ask the database to refuse a duplicate key.

Append to the same file:

LINES = [{"product_id": 2, "qty": 1, "unit_price_kobo": 350_000}]


def test_the_database_refuses_a_second_order_with_the_same_key(db, clock):
    db.save_order("key-1", 350_000, "ch_1", clock.now(), LINES)
    with pytest.raises(sqlite3.IntegrityError):
        db.save_order("key-1", 350_000, "ch_2", clock.now(), LINES)
.venv/bin/pytest tests/integration/test_database.py -q -p no:randomly
1 failed, 3 passed. The failure reads Failed: DID NOT RAISE <class 'sqlite3.IntegrityError'>. The second save_order succeeded: orders_key in checkout/db.py is a plain CREATE INDEX, not a UNIQUE one. The only guard is the look-up inside place_order.

4. Record the gap, and prove the test can pass.

Put this line above test_the_database_refuses_a_second_order_with_the_same_key:

@pytest.mark.xfail(strict=True, reason="orders_key is a plain index, not UNIQUE (checkout/db.py, SCHEMA)")

Then append a fixture and a test that add the constraint to the test’s own file:

@pytest.fixture
def keyed_db(db):
    """The same file with the rule we want: one order per idempotency key."""
    with closing(sqlite3.connect(db.path)) as conn, conn:
        conn.execute("DROP INDEX orders_key")
        conn.execute("CREATE UNIQUE INDEX orders_key ON orders (idempotency_key)")
    return db


def test_a_unique_index_would_make_the_key_a_rule(keyed_db, clock):
    keyed_db.save_order("key-1", 350_000, "ch_1", clock.now(), LINES)
    with pytest.raises(sqlite3.IntegrityError, match="idempotency_key"):
        keyed_db.save_order("key-1", 350_000, "ch_2", clock.now(), LINES)
    assert keyed_db.count_orders() == 1
.venv/bin/pytest tests/integration/test_database.py -q -p no:randomly
4 passed, 1 xfailed, and in the summary an XFAIL line carrying your reason. The unique index makes the same call raise UNIQUE constraint failed: orders.idempotency_key, so the test was right. Do not change the lab’s schema here: the concurrency chapter comes back to it and makes the fix.

5. Rollback and compensation.

Append:

def test_a_failed_line_insert_rolls_back_the_order_row(db, clock):
    bad_lines = [{"product_id": 2, "qty": 1}]  # no unit_price_kobo: KeyError after the order row is written
    with pytest.raises(KeyError):
        db.save_order("key-1", 350_000, "ch_1", clock.now(), bad_lines)
    assert db.count_orders() == 0


class ProviderDown:
    def charge(self, reference, amount_kobo, idempotency_key):
        raise PaymentUnavailable("provider returned 500")


def test_a_provider_outage_puts_the_stock_back_and_writes_no_order(db, clock):
    with pytest.raises(PaymentUnavailable):
        place_order(db, ProviderDown(), clock, [{"product_id": 2, "qty": 3}], "key-1")
    assert db.stock_of(2) == 100
    assert db.count_orders() == 0
.venv/bin/pytest tests/integration -q -p no:randomly
12 passed, 1 xfailed: your six passing tests and the xfail, the starter’s two, the three API tests and the search index’s one. The first new test is a rollback by the database; the second is a compensation by release_all.

Now see the rollback test earn its place. In checkout/db.py, add one line after conn.row_factory = sqlite3.Row in _tx: conn.isolation_level = None, which puts the connection in autocommit mode. Run the file again, then remove the line.

.venv/bin/pytest tests/integration/test_database.py -q -p no:randomly
1 failed, 5 passed, 1 xfailed. The failure is assert 1 == 0 on count_orders() in test_a_failed_line_insert_rolls_back_the_order_row: with autocommit, the order row was committed before the KeyError. Nothing else noticed. Remove the line and the file is green again.

6. The same tests against a dict.

Create tests/dict_db.py:

"""A dict-based stand-in for checkout.db.Database: the same methods, no SQL."""

import uuid


class DictDatabase:
    def __init__(self):
        self.stock = {1: 50, 2: 100, 3: 5, 4: 10}
        self.prices = {1: 1_200_000, 2: 350_000, 3: 650_000, 4: 900_000}
        self.status = {1: "published", 2: "published", 3: "published", 4: "draft"}
        self.orders = {}

    def get_product(self, product_id):
        if product_id not in self.prices:
            return None
        return {"id": product_id, "price_kobo": self.prices[product_id], "status": self.status[product_id]}

    def stock_of(self, product_id):
        return self.stock.get(product_id, 0)

    def take_stock(self, product_id, qty):
        if self.stock.get(product_id, 0) < qty:
            return False
        self.stock[product_id] -= qty
        return True

    def give_stock(self, product_id, qty):
        self.stock[product_id] += qty

    def find_order_by_key(self, key):
        return next((o for o in self.orders.values() if o["idempotency_key"] == key), None)

    def save_order(self, key, total_kobo, charge_id, created_at, lines):
        order = {"id": "ord_" + uuid.uuid4().hex[:12], "idempotency_key": key, "status": "paid",
                 "total_kobo": total_kobo, "charge_id": charge_id, "created_at": created_at.isoformat()}
        self.orders[order["id"]] = order
        order["lines"] = [
            {"product_id": ln["product_id"], "qty": ln["qty"], "unit_price_kobo": ln["unit_price_kobo"]}
            for ln in lines
        ]
        return order

    def count_orders(self):
        return len(self.orders)

Create tests/integration/test_same_tests_two_stores.py:

"""The same three behaviours against the real sqlite file and against a dict."""

import pytest

from checkout.inventory import OutOfStock, reserve_all
from checkout.orders import place_order
from tests.dict_db import DictDatabase


@pytest.fixture(params=["sqlite", "dict"])
def store(request, db):
    return db if request.param == "sqlite" else DictDatabase()


def test_a_shortfall_puts_back_the_lines_already_taken(store):
    with pytest.raises(OutOfStock):
        reserve_all(store, [{"product_id": 2, "qty": 10}, {"product_id": 3, "qty": 6}])
    assert store.stock_of(2) == 100
    assert store.stock_of(3) == 5


def test_a_replayed_key_writes_one_order(store, payments, clock):
    items = [{"product_id": 2, "qty": 1}]
    place_order(store, payments, clock, items, "key-1")
    place_order(store, payments, clock, items, "key-1")
    assert store.count_orders() == 1


def test_a_failed_line_insert_leaves_no_order(store, clock):
    with pytest.raises(KeyError):
        store.save_order("key-1", 350_000, "ch_1", clock.now(), [{"product_id": 2, "qty": 1}])
    assert store.count_orders() == 0
.venv/bin/pytest tests/integration/test_same_tests_two_stores.py -v -p no:randomly
Six results: five PASSED and test_a_failed_line_insert_leaves_no_order[dict] FAILED (1 failed, 5 passed). The dict kept the order row when the line list raised halfway, which the real file’s rollback would not. The fake is the one that is wrong.

7. Damage the real code and see who notices.

In Database.take_stock in checkout/db.py, delete AND on_hand >= ? from the SQL and one qty from the argument tuple ((qty, product_id)). Run:

.venv/bin/pytest tests/integration -q -p no:randomly
3 failed, 15 passed, 1 xfailed. The failures are the two shortfall tests on the real file (DID NOT RAISE OutOfStock, one in each file) and the dict’s rollback test from step 6, which was already red. test_a_shortfall_puts_back_the_lines_already_taken[dict] is green: the dict has its own copy of the rule and never ran the line you broke. Put the line back before the next step.
Make the tests share a file. In tests/conftest.py change the db fixture to database = Database("/private/tmp/shared-test.sqlite") (a fixed path, so every test gets the same file), delete that file if it exists, and run .venv/bin/pytest tests/integration -q three times. On the lab machine the result was 8 to 10 failures and one error each time, and the number changed between runs, because random order (pytest-randomly) decides which test meets which leftovers and the seed step is skipped once the file has products. Run one test alone and it passes. That is the order-dependent suite from the lesson. Put tmp_path back, and delete the shared file.

Put the lab back. Run git checkout checkout/db.py tests/conftest.py and delete tests/integration/test_database.py, tests/integration/test_same_tests_two_stores.py, tests/dict_db.py and /private/tmp/shared-test.sqlite. The next chapter counts from 23 passed, 1 skipped, 1 deselected.

DECIDE

Fikre's team wants a real-database layer for the orders code. The service runs on a managed Postgres in production. The team has 300 dict-based tests, a CI that takes four minutes, and an engineer, Gaone, who offers to port the tests to SQLite files 'because it is quick'. Fikre must choose what the layer runs on.

READING
  1. DOC
    How SQLite Is Tested SQLite project

    The most thorough account of testing a database engine: four harnesses, crash and I/O-error simulation, fuzzing and branch coverage. Read the introduction, 'Anomaly Testing' and 'Test Coverage' for the attitude. Skip the release checklists on a first read.

  2. DOC
    How to use temporary directories and files in tests pytest

    The reference for tmp_path and tmp_path_factory, and for how many old temp directories pytest keeps. Read it before you write your own fixture around a file or a database.

  3. BOOK
    Unit Testing Principles, Practices, and Patterns Vladimir Khorikov, 2020

    Argues which dependencies to keep real and gives practical rules for database tests, including the database schema as a thing to test. Read those chapters; skip the C# specifics and take the ideas. Read: the chapters on integration testing and on testing the database.

  4. POST
    Testing Strategies in a Microservice Architecture Toby Clemson, 2014

    Defines integration tests as tests of a module's contact with another component, and places them among unit, component and contract tests. Read the integration-testing section for the vocabulary; skip the sections on a microservice you do not run.

  5. DOC
    Foreign Key Support SQLite project

    The page that states foreign keys are off by default and must be enabled per connection with PRAGMA foreign_keys. Read the first sections before trusting any SQLite test of referential integrity.

  6. DOC
    Testing FastAPI

    How TestClient exercises the API in process, which is how the lab's api tests run with a temporary database behind them. Read it before the API-and-contract chapter; skip the async material.

All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.
NEXT: API and contract tests →