Giter Club home page Giter Club logo

spring-boot-test-container's Introduction

Spring Boot integration tests with TestContainers (PostgreSQL)

Overview

Use Testcontainers for integration testing with Spring Data JPA and the PostgreSQL database. Detailed overview can be found on the blog

Package the application

  • Package the application

$ ./mvnw clean package

To skip the tests use: -DskipTests=true

Run Application

$ mvn spring-boot:run

Verify that postgres container is initialized

Docker will pull the specified image and can be seen in Test logs.

2020-05-12 12:00:32.701  INFO 470540 --- [           main] org.testcontainers.DockerClientFactory   : Checking the system...
2020-05-12 12:00:32.702  INFO 470540 --- [           main] org.testcontainers.DockerClientFactory   : ✔︎ Docker server version should be at least 1.6.0
2020-05-12 12:00:32.828  INFO 470540 --- [           main] org.testcontainers.DockerClientFactory   : ✔︎ Docker environment should have more than 2GB free disk space
2020-05-12 12:00:32.874  INFO 470540 --- [           main] 🐳 [postgres:11.1]                       : Creating container for image: postgres:11.1
2020-05-12 12:00:33.655  INFO 470540 --- [           main] o.t.utility.RegistryAuthLocator          : Credential helper/store (docker-credential-desktop) does not have credentials for index.docker.io
2020-05-12 12:00:34.581  INFO 470540 --- [           main] 🐳 [postgres:11.1]                       : Starting container with ID: a77f81e6b7278138b8829bb907a2eed66ed9c03a4dcd905f3bcf51a6d841300a
2020-05-12 12:00:36.346  INFO 470540 --- [           main] 🐳 [postgres:11.1]                       : Container postgres:11.1 is starting: a77f81e6b7278138b8829bb907a2eed66ed9c03a4dcd905f3bcf51a6d841300a
2020-05-12 12:00:42.060  INFO 470540 --- [           main] 🐳 [postgres:11.1]                       : Container postgres:11.1 started in PT15.1360412S
2020-05-12 12:00:42.198  INFO 470540 --- [           main] org.testcontainers.ext.ScriptUtils       : Executing database script from initscript.sql

spring-boot-test-container's People

Contributors

praveengnair avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.