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, Cloud SQL, 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 substitutes stand-in data for a routine's dependency tables, but it reads their real columns and constraints.

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

  • Community Edition. The default unit-test command is free and needs no licence.
  • Team. Needed for integration.
  • Enterprise. Needed for seccover, pii and hipaa. Startup and trial licences include them too.

UnitAutogen picks up your licence automatically. Place unitautogen.lic in the folder you run it from, or pass --license PATH. A paid command run without its licence reports NOT LICENSED, generates nothing, and exits with code 5.