FAQ and troubleshooting

Coverage is 100% statement but less than 100% branch. Why?

A result-set query has a condition that no committed test exercised on both sides, for example a date-range filter. The report names the exact untested condition so you can add data that trips it, or confirm the other side is unreachable.

A routine shows "tests generated, coverage skipped".

plpgsql_check is not installed in that database. Tests are still generated and run. Install the extension to get branch and statement numbers.

A test was "pruned". Is that a failure?

No, the opposite. A generated test did not pass a clean re-run, so it would have been flaky. It was dropped and the branch reported honestly instead. Pruned tests are listed in the JSON so you can see exactly what was set aside and why.

Coverage looks low for a routine whose conditions look simple.

Usually a specific precondition is not being met, a required row, an upsert target, a date gate. The report's per-line explanations name the blocker. If it turns out to be a limit of the tool (an E tag), reporting the routine is the most useful thing you can do. See Reading the report.

It says "CANNOT CONNECT" (exit code 4).

The database could not be reached with the settings in your environment. The first line names where the settings came from, a connection string variable or the host, port, database and user from the PG* variables. A leftover DATABASE_URL is a common cause, since it wins over the PG* variables. Unset it, or set UNITAUTOGEN_DSN to the database you mean. See Connecting.

Do I commit the generated tests?

Yes. The generated .sql files are ordinary pgTAP. Commit them next to your code and run them in CI. When a routine's intended behaviour changes, re-generate (or accept the new recorded output) and commit the update.

A paid command stopped with exit code 5 and generated nothing.

It found no licence that covers that command. Place unitautogen.lic in the folder you run from, or pass --license PATH. integration needs Team; seccover, pii and hipaa need Enterprise.

Do I have to tag which tables hold PHI for the HIPAA report?

No. Which tables and columns hold PHI is decided automatically. When the tool misses a PHI table or an audit table, or picks a wrong one, declare it in the config file. The report marks everything taken from the file, so your declarations never read as findings of the tool.

How do I send a debug log?

Add --debug to the command. It writes unitautogen-debug-<time>.log in the folder you ran from, where <time> is the start of the run as YYYYMMDD-HHMMSS. Send that one file, or name it yourself with --debug mylog.log. The log holds the tool version, the command, the system, the database server and extension versions, the settings with passwords masked, the console output and whether the run finished. --debug never changes what is generated.

Which command should I use day to day?

Start with unitautogen --schema public --out unit_tests --html report.html, since unit tests are the default. Reach for integration when routines call each other, seccover for security review (it includes the PII audit), and hipaa for HIPAA evidence.

Generated tests are standard pgTAP; coverage is measured with plpgsql_check. All command output shown in these docs was produced by running the actual unitautogen commands against live databases.