Prerequisites

  • The unitautogen executable. A single self-contained binary, with no Python installation and no dependencies to manage. Put it on your PATH, or call it by full path.
  • PostgreSQL 14 to 18, with two required extensions installed in the database you are testing.

The two extensions are pgTAP (the framework the generated tests are written in) and plpgsql_check (the coverage meter). Both are required. UnitAutogen checks for them before it generates anything and stops with a clear message (exit code 3) if either is missing, naming the exact command to run, so you never get a half-finished run.

Installing pgTAP and plpgsql_check

Both are standard PostgreSQL extensions, added in two steps. Install the extension on the database server once (a one-time DBA action), then enable it in each database you test.

1. Install on the server

  • Debian / Ubuntu (PostgreSQL PGDG apt repo), for PostgreSQL 16: sudo apt install postgresql-16-pgtap postgresql-16-plpgsql-check (swap 16 for your major version).
  • RHEL / Rocky / Alma (PGDG yum repo): sudo dnf install pgtap_16 plpgsql_check_16.
  • Windows or from source. pgTAP is pure SQL on PG14+ (no compiler needed), installed from the pgTAP distribution. plpgsql_check is compiled, so use a prebuilt build matching your PostgreSQL major version and place its files in PostgreSQL's lib and share/extension directories.
  • Managed and cloud PostgreSQL (Supabase, Neon, Amazon RDS and Aurora, Azure Database for PostgreSQL, and similar). Both are frequently available already, so just run the CREATE EXTENSION step below. If a provider does not offer one, check its supported-extensions list or ask its support to enable it.

2. Enable in each database you test

Once per database, with a role allowed to create extensions:

CREATE EXTENSION IF NOT EXISTS pgtap;
CREATE EXTENSION IF NOT EXISTS plpgsql_check;

This is exactly the command UnitAutogen prints when it detects a missing extension. Extensions are per-database, so repeat this step for every database you point the tool at.

The tables your routine reads must exist in the database, along with any custom types they use, even if empty. UnitAutogen does not need them populated, but it does need them to be there.

Privilege note

Plain functions need no special rights. A few advanced setups, around triggers, circular foreign keys, and role-dependent branches, need a superuser or replication-capable role. Without it, those specific branches are skipped honestly (reported NOT_TESTABLE) rather than faked. Licensing is by command: the default unit-test generation is free, integration needs a Team licence, and seccover and --pii need an Enterprise licence.