Freedom251 › Database Testing Tools
pgTAP

What pgTAP is
pgTAP provides database functions for building unit tests against PostgreSQL. It can run checks written in psql scripts or in xUnit-style test functions, using SQL, PL/pgSQL, or PL/SQL. Assertions cover schema structures such as tables, columns, primary keys, and function signatures, along with database values and behavior in views, procedures, functions, rules, and triggers. The tests emit TAP-formatted results that a TAP harness can collect and report, and the project describes using pg_prove to run them. Its runtests() approach isolates each test by rolling back schema changes, while allowing startup, setup, teardown, and shutdown routines. Documentation includes workflows involving Perl and PostgreSQL modules and refers to PHP and Python testing frameworks. pgTAP is self-hosted on Linux: installation happens on a machine running PostgreSQL and cannot be performed remotely. PostgreSQL 9.1 or newer is required. The software is free, and its license permits use, copying, modification, and distribution under stated conditions. That license places no obligation on the author to provide maintenance, support, updates, enhancements, or modifications.
Who it suits
pgTAP suits PostgreSQL teams that want SQL-based schema, data, and behavior tests in self-hosted environments. It is useful for developers working with migration checks, stored procedures, triggers, and TAP-based reporting.
What it does well
- Checks tables, columns, keys, and function signatures
- Exercises views, procedures, rules, triggers, and database values
- Supports psql scripts and xUnit-style test functions
- TAP output works with harnesses and pg_prove
- Per-test rollback with setup and teardown hooks
- Free license permits copying and modification
What to know first
- Requires PostgreSQL 9.1 or newer
- Must run on a host with PostgreSQL installed
- Remote installation is unavailable
- License provides no support or maintenance obligation
Getting started
- Open the pgTAP website
- Use a Linux host running PostgreSQL
- Install pgTAP on that PostgreSQL host
- Write tests in psql scripts or xUnit-style functions
- Run the tests with pg_prove or another TAP harness
Verdict
Choose pgTAP when PostgreSQL database testing belongs inside a self-hosted SQL workflow and you need TAP results. Its broad assertions and rollback-enabled xUnit style cover schema and behavior checks. Look elsewhere if you need remote installation or a committed support and maintenance service.
Questions
What does pgTAP test?
It tests schema objects, database values, views, procedures, functions, rules, and triggers, including migration-related checks.
Which databases does pgTAP support?
pgTAP is for PostgreSQL and requires PostgreSQL 9.1 or newer.
Can pgTAP be installed remotely?
No. It must be installed on a host where PostgreSQL is running.
What test formats are supported?
You can write tests in psql scripts or xUnit-style functions using SQL, PL/pgSQL, or PL/SQL.
How are results reported?
pgTAP emits TAP output that a TAP harness can collect and report; the project describes running tests with pg_prove.
Is pgTAP free to use?
Yes. The license allows use, copying, modification, and distribution under its stated conditions.
Facts from pgTAP's own pages
- Database behavior
- Tests can exercise database views, procedures, functions, rules, and triggers. · pgtap.org, 2 Oct 2026
- Database requirement
- The package documentation says pgTAP requires PostgreSQL 9.1 or higher. · pgxn.org, 3 Oct 2026
- Database testing
- Its assertion functions can test database values and exercise views, procedures, functions, rules, and triggers. · pgtap.org, 3 Oct 2026
- Hosting requirement
- pgTAP must be installed on a host with PostgreSQL running and cannot be installed remotely. · pgxn.org, 3 Oct 2026
- Installation
- pgTAP must be installed on a host running PostgreSQL and cannot be installed remotely. · pgxn.org, 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. · pgtap.org, 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. · pgtap.org, 3 Oct 2026
- Latest listed release
- PGXN lists pgTAP 1.3.4 as the stable release, dated 2025-10-04. · pgxn.org, 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. · pgxn.org, 3 Oct 2026
- PostgreSQL requirement
- The release page says pgTAP requires PostgreSQL 9.1 or higher. · pgxn.org, 2 Oct 2026
- Purpose
- pgTAP is a PostgreSQL unit testing framework that emits TAP from psql scripts or xUnit style test functions. · pgtap.org, 3 Oct 2026
- Schema testing
- The framework includes functions for checking schema objects such as tables, columns, and primary keys. · pgtap.org, 3 Oct 2026
- Support
- The license says the author has no obligation to provide maintenance, support, updates, enhancements, or modifications. · pgxn.org, 2 Oct 2026
- Support terms
- The package license disclaims any obligation to provide maintenance, support, updates, enhancements, or modifications. · pgxn.org, 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. · pgtap.org, 2 Oct 2026
- Test output
- pgTAP emits TAP output that can be collected and reported by a TAP harness. · pgtap.org, 2 Oct 2026
- Test runner
- pg_prove can run pgTAP tests and display TAP results. · pgtap.org, 3 Oct 2026
- Test styles
- pgTAP supports both scripting style tests and xUnit style tests, including setup and teardown functions for xUnit tests. · pgtap.org, 3 Oct 2026
Where pgTAP stands on Freedom251
- Database Testing Tools#20 of 28