Skip to content

VavelinDev/example-liquibase-integration-tests

Repository files navigation

Integration Tests with Liquibase, Oracle and Spring Boot

example-intest-liquibase.png

This demo project showcases the execution of integration tests using Liquibase, even in the absence of Testcontainers or Docker. The primary objectives of the project are twofold:

  1. Conducting integration tests efficiently by leveraging Liquibase to set up databases, often of a complex nature.
  2. Executing tests against pre-installed instances of the Oracle Database, a common scenario in many companies.

Note: Despite the emphasis on point 2, the project includes a docker-compose script to facilitate running the Oracle Instance.

Prerequisites

  • Docker or any Oracle Instance
  • JDK 17, make sure that the JAVA_HOME environment variable is properly configured

Before you run the integration tests (set up)

These are the prerequisites that should be completed once before running the integration tests.

Oracle Container (Docker)

This method involves starting a preconfigured database instance as a Docker container. From the project directory, run the following command:

docker-compose up -d oracle

⏳ The Docker image is downloaded during the first build, so it may take a little longer than usual.

If you choose this approach, both the database instance and the required adminuser user are created automatically when the Oracle container starts.

Local Oracle Instance

If you have your own local Oracle setup, you should create an adminuser. To do that, execute the script ./database/src/main/resources/init/users.sql using a user with the DBA role. This user is utilized by the integration tests to set up all the necessary database objects on the fly. This step is automatic when running the Oracle Container.

Run the integration tests

Once you have the Oracle instance configured, you can run the integration tests:

./gradlew build intest

Sources

Przemek Malirz's VShop application on GitHub

Oracle Container Registry - Docker Image Documentation

Getting Started with Liquibase and Gradle

Gradle - processResources with filesMatching

Instead of setting up the gradle intest configuration manually you can use Przemek Malirz's intest-gradle-plugin

Gradle - Working With Files

Spring Boot Gradle Plugin Reference Guide

Releases

No releases published

Packages

No packages published