pgtap
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pgtap | 1.3.4 | LANG | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3200 | pgtap | No | Yes | No | Yes | No | No | - |
| Related | plpgsql faker dbt2 pg_mockable pgsqlmock omni_test random tsm_system_time tsm_system_rows |
|---|---|
| Depended By | pgsqlmock |
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 1.3.4 | 1817161514 | pgtap | plpgsql |
| RPM | PGDG | 1.3.4 | 1817161514 | pgtap_$v | - |
| DEB | PGDG | 1.3.4 | 1817161514 | postgresql-$v-pgtap | - |
Install
You can install pgtap directly. First, make sure the PGDG repository is added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
Sources:
pgtap is a unit testing framework for PostgreSQL that produces TAP (Test Anything Protocol) output, providing hundreds of assertion functions for testing database objects and query results.
Test Structure
Use no_plan() when the test count is not known in advance:
Basic Assertions
Schema Testing
Error Testing
Query Result Testing
Running Tests with pg_prove
xUnit Style
Version 1.3.4 and Test Boundaries
Version 1.3.4 adds index_is_partial() and name/name overloads of has_composite() and hasnt_composite(), and repairs several older upgrade paths. Install the matching scripts before ALTER EXTENSION pgtap UPDATE TO '1.3.4'. The control file requires plpgsql, sets superuser = false, and permits relocation; shared preload is unnecessary. A role still needs CREATE on the database and suitable privileges for the objects a test exercises.
Run tests against disposable fixtures or an isolated test database. Transaction rollback does not undo external actions performed by the functions being tested. The pg_prove client must be installed separately; extension installation alone does not provide that runner.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)