pgTAP
pgTAP is a free suite of database functions for writing PostgreSQL unit tests that emit TAP output.
What pgTAP is
pgTAP is a free suite of database functions for writing PostgreSQL unit tests that emit TAP output. Tests can be written in psql scripts or as xUnit-style functions, and can check schema elements such as tables, columns, primary keys, and function signatures. They can also exercise database values, views, procedures, functions, rules, and triggers. A TAP harness can collect and report the output, and the project describes running tests with pg_prove. The xUnit-style runtests() function rolls back schema changes made during each test and supports setup, teardown, startup, and shutdown functions. Integration guidance covers Perl and PostgreSQL module workflows, and mentions PHP and Python testing frameworks. pgTAP must be installed on a host where PostgreSQL is running; it cannot be installed remotely. PostgreSQL 9.1 or higher is required. Its license allows use, copying, modification, and distribution under stated conditions, but does not obligate the author to provide support, maintenance, or updates.
Good
- Checks schema objects and database behavior.
- Tests can be written in psql scripts or xUnit style.
- Emits TAP output for collection by a harness.
- Test runs can roll back schema changes.
Watch out
- Cannot be installed remotely.
- Requires PostgreSQL 9.1 or higher.
- The author has no obligation to provide support or updates.
- PHP and Python integration guidance invites users to submit instructions.
Who it suits
pgTAP suits PostgreSQL users who want SQL-based tests for schema objects and database behavior. It is intended for environments where PostgreSQL is running on the host that will have pgTAP installed.
Verdict
pgTAP offers a focused way to test PostgreSQL schemas and behavior, with TAP output and rollback support for xUnit-style tests. Plan for local installation and do not rely on the license for ongoing support or updates.
The facts
Each one read from pgTAP's own pages, with the date it was checked.
What it does
- Database behavior
- Tests can exercise database views, procedures, functions, rules, and triggers.checked 2 Oct 2026
- Database requirement
- The package documentation says pgTAP requires PostgreSQL 9.1 or higher.checked 3 Oct 2026
- Database testing
- Its assertion functions can test database values and exercise views, procedures, functions, rules, and triggers.checked 3 Oct 2026
- Hosting requirement
- pgTAP must be installed on a host with PostgreSQL running and cannot be installed remotely.checked 3 Oct 2026
- Installation
- pgTAP must be installed on a host running PostgreSQL and cannot be installed remotely.checked 2 Oct 2026
- Integration guidance
- The integration page mentions PHP and Python testing frameworks but says users should send instructions for those integrations to the project's mailing list.checked 3 Oct 2026
- Integrations
- The integration guide describes running pgTAP tests with Perl's Test::Harness and TAP::Harness, and with PostgreSQL module testing tools.checked 3 Oct 2026
- Latest listed release
- PGXN lists pgTAP 1.3.4 as the stable release, dated 2025-10-04.checked 3 Oct 2026
- License
- The PGXN package page grants permission to use, copy, modify, and distribute pgTAP and its documentation without a fee, subject to the stated conditions.checked 3 Oct 2026
- PostgreSQL requirement
- The release page says pgTAP requires PostgreSQL 9.1 or higher.checked 2 Oct 2026
- Purpose
- pgTAP is a PostgreSQL unit testing framework that emits TAP from psql scripts or xUnit style test functions.checked 3 Oct 2026
- Schema testing
- The framework includes functions for checking schema objects such as tables, columns, and primary keys.checked 3 Oct 2026
- Support
- The license says the author has no obligation to provide maintenance, support, updates, enhancements, or modifications.checked 2 Oct 2026
- Support terms
- The package license disclaims any obligation to provide maintenance, support, updates, enhancements, or modifications.checked 3 Oct 2026
- Test isolation
- The xUnit-style runtests() function rolls back changes made to the schema during each test and supports setup, teardown, startup, and shutdown functions.checked 2 Oct 2026
- Test output
- pgTAP emits TAP output that can be collected and reported by a TAP harness.checked 2 Oct 2026
- Test runner
- pg_prove can run pgTAP tests and display TAP results.checked 3 Oct 2026
- Test styles
- pgTAP supports both scripting style tests and xUnit style tests, including setup and teardown functions for xUnit tests.checked 3 Oct 2026
Alternatives to pgTAP
- 1

Atlas
Free planOpen sourceWebAPILinuxmacOS8.3From $39 a month - 2

DataKitchen TestGen
Free planOpen sourceWebAPILinuxmacOS8.1From $100 a month - 3

Soda
Free planWebAPILinuxSelf-hosted7.5From $750 a month - 4
Avidemux
Free planOpen sourceWebLinuxmacOSWindows7.3Free plan - 5
pgroll
Free planOpen sourceLinuxmacOSSelf-hostedWindows7.3Free plan - 6

Bytebase Enterprise
Free planWebAPISelf-hosted6.8From $20 a month
