Code Monkey home page Code Monkey logo

pgtap-java's Introduction

pgtap-java

CI Maven Central License

A library for running pgTAP tests using Testcontainers for Java.

A screenshot demonstrating pgTAP test results and descriptions displayed in the IntelliJ Run tool window

Installation

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>

Usage

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 files
  • pgTapTmpPath: 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.

Acknowlegements

This project wouldn't exist without the work of theory, rnorth and the many pgTAP and Testcontainers contributors.

License

All code in this repository is licensed under the Apache License, Version 2.0. See LICENSE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.