Testing and continuous integration
Introduced
Vocabulary
| English | Meaning |
|---|---|
| test pyramid | test pyramid |
The pyramid
- The test pyramid: many unit tests (fast, isolated), fewer integration tests (real database), few end-to-end tests (the whole app). CI runs them on every push: red blocks the merge.

{exercise:uni-cs1205-pyramid}
Practice
The pyramid puts — at the base
Difficulty 1/5 · 100 coins + a small bonus on first completion today
Many fast units, fewer integration, few slow end-to-end.
Coverage, honestly
- Line coverage counts executed lines; branch coverage counts decided branches. The course suite: 92% line, 81% branch — the branch number is the honest one (each untested branch is an untested behaviour).
- The gate at 85% line blocks merges; the uncovered branch list is the work queue. A test without an assertion is coverage theatre.
{exercise:uni-cs1205-coverage}
Practice
Branch coverage is the honest number because —
Difficulty 1/5 · 100 coins + a small bonus on first completion today
92% line with 81% branch: the gap is decisions never exercised.
FR-2 at all three levels
- Unit: due = borrow date + 21 — three cases (normal, leap February, year boundary). Integration: the loan lands and reads back. End-to-end: a scripted member borrows and sees the due date.
- Red-green in CI: push the failing sixth-borrow test, CI red; implement the limit check, green, coverage rises, merge unblocked. Assert behaviour (the due date), not internals.
{exercise:uni-cs1205-levels}
Practice
Due = borrow date + 21 is tested at the unit level with —
Difficulty 1/5 · 100 coins + a small bonus on first completion today
Pure function: normal, leap February, year boundary.