Generate unit tests and a coverage report for every function and trigger in the public schema. Generating unit tests is the default action, so you do not type a command word.
unitautogen --schema public --out unit_tests --html report.html --json report.json
unitautogen.exe; on Linux invoke ./unitautogen (or add its folder to PATH to drop the ./). Every command, flag, and report is identical on both.You will see one line per routine and a summary. Real output from a sample database:
public.account_health: 14 tests kept, branch 100% / stmt 100% [test_account_health.sql]
public.accrue_interest: 15 tests kept, branch 100% / stmt 100% [test_accrue_interest.sql]
public.transfer_funds: 15 tests kept, 1 pruned -> NT, branch 100% / stmt 100% [test_transfer_funds.sql]
== done: 72 tests across 6 routines, avg branch 100.0% -> unit_tests/ ==
That single command produced runnable pgTAP tests for the functions (one test_<routine>.sql file each in unit_tests/), plus behaviour tests for the triggers (in unit_tests/trigger_tests/), an HTML report, and a JSON summary. A "1 pruned -> NT" note is the guarantee at work, a test that would not pass cleanly is dropped and the branch reported honestly, never faked.
Run the generated tests yourself at any time:
psql -d mydb -c "SELECT * FROM runtests('test_transfer_funds'::name);"
Point the tool at a throwaway copy of your database, never production, and make sure pgTAP and plpgsql_check are installed there. See Prerequisites and Connecting.