Integration testing (Team)

Unit testing isolates a routine and stands in for its dependencies. integration runs the whole call map for real, a function together with the functions it calls and the triggers its writes fire, and measures coverage across that map. Every routine in the schema becomes an integration test, including ones that call nothing, so one run is a complete suite for the schema. Team edition.

unitautogen integration --schema public --out integration_tests --html integration.html --json integration.json

What it writes

  • Integration-level pgTAP tests for every routine in <out>/integration/<schema>/, under functions/, triggers/ and views/
  • The CI report bundle in <out>/integration/
  • The HTML report and the JSON summary
  • --out defaults to integration_tests/

The older behaviour, where routines that call nothing were handed to the unit tests instead, is available with TG_INTEGRATION_ROOTS_ONLY=1. It then lists them in _integration_skipped.json.

Options

  • --schema a,b and --like pat
  • --out DIR, --html PATH, --json PATH
  • --no-report skip the CI bundle
  • --no-coverage and --include-extension

It needs a Team licence or above. Without one it reports NOT LICENSED, runs nothing and exits with code 5. See Prerequisites for where the licence file goes. On Supabase, run unitautogen --supabase integration --schema public, which writes to supabase/tests/seccover/integration/.

The HTML report

The --html file is the Integration Testing Report. It has the same four summary cards as the unit report, measured across the whole call map, and one row per routine. Callers show their real callees, and leaves show an empty callee set.

Integration testing report with the call-map coverage table
A sample schema of connected routines. 28 routines, 186 tests, 100% map coverage. The EXT:1 tag marks an external boundary the map does not run, such as a remote dblink call.
Report elementWhat it shows
Summary cardsLine and branch coverage, test counts and autonomy, line-weighted over the whole call map the tests drove.
One row per routineFor a caller, its tests call it directly, and every function it calls and every trigger its writes fire runs for real underneath it. A leaf routine is covered as its own node.
StandaloneA routine that calls nothing and fires no triggered write. It is still tested here, with an empty callee set.
Lines, line %, branch %Line-weighted over the call map the root's tests drove. A line counts only if the root's call reached it.
Click a rootThe call map in real call order, the write footprint per test across the whole map, and the stitched annotated source of every function in it.
Integration call-map drill-down with write footprint, call tree and stitched source
iz18_root. The write footprint across the whole map, the call map from the root through its helper to the trigger its insert fired, and the stitched source with hit counts.

Every function and trigger here ran for real, so the stitched source shows the callee's and the trigger's coverage too. A line that is uncovered here is one the root's inputs never drove through the whole chain.

Each routine gets a full set of tests, not one. Valid inputs, boundaries and one test per branch, all driven through the real call map. In the run above iz17_root has 9 tests and iz18_root has 7.

Use it to

  • Verify a whole flow end to end, a function with everything it calls and fires
  • Find lines that are only reachable through the real call map