A library for running pgTAP tests using Testcontainers for Java.
pgtap-java is published for Java 11 and above.
Gradle (build.gradle / build.gradle.kts):
testing {
suites {
val test by getting(JvmTestSuite::class) {
dependencies {
implementation("com.opencastsoftware:pgtap-java:0.1.0")
}
}
}
}
Maven (pom.xml):
<dependency>
<groupId>com.opencastsoftware</groupId>
<artifactId>pgtap-java</artifactId>
<version>0.1.0</version>
<scope>test</scope>
</dependency>
pgtap-java is intended for use with JUnit 5 and Testcontainers for Java.
In order to run pgTAP tests with pgtap-java, you must extend the PgTapTest abstract class provided by this library.
PgTapTest
requires 3 constructor parameters:
database: PostgreSQLContainer<?>
- a Testcontainers PostgreSQL database container. This container image must have pgTAP preinstalled. See our postgres-with-pgtap Containerfile for an example of how you can do that.pgTapTestPath: Path
- the path to your pgTAP.sql
test filespgTapTmpPath: Path
- the path where the pgTAP.sql
test files will be mounted inside the PostgreSQL container.
In order for your tests to run, you should use withCopyFileToContainer to mount the pgTapTestsPath
at pgTapTmpPath
in your database
container.
It doesn't matter precisely what pgTapTmpPath
you use, as long as you use the same path in the constructor of PgTapTest
and with withCopyFileToContainer
.
See ExampleTest for an end-to-end example that uses Flyway migrations to set up a test database.
This project wouldn't exist without the work of theory, rnorth and the many pgTAP and Testcontainers contributors.
All code in this repository is licensed under the Apache License, Version 2.0. See LICENSE.