Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 1.64 KB

File metadata and controls

58 lines (38 loc) · 1.64 KB

Testcontainers with Spring Boot in Kotlin

In this example, I have created a simple Spring Boot project integrated with JPA to interact with a PostgreSQL database.

This project includes two sets of tests:

  • Unit Tests:

    • Uses a local machine's postgres database for testing.
  • Integration Tests with Testcontainers:

    • Uses Testcontainers to run tests with a real PostgreSQL container.

Testcontainers

Testcontainers, a powerful Java library that simplifies and enhances the testing of your applications by providing disposable containers for databases, web browsers, and more.

Testcontainers allows you to write more realistic and reliable tests by running your dependencies, such as databases, in isolated containers.

  • Easily Manage Dependencies:

    • Run databases, queues, and other services as Docker containers for testing purposes.
  • Realistic Testing:

    • Testcontainers allows you to test against real instances of your dependencies, ensuring a more accurate representation of your production environment.
  • Disposable Containers:

    • Containers are started before tests and stopped afterward, ensuring a clean and isolated environment for each test.

Getting Started

  1. Clone the Repository:
git clone https://github.com/shaikrasheed99/kotlin-springboot-testcontainers-example
  1. Move to the project directory:
cd kotlin-springboot-testcontainers-example
  1. Build the Project:
./gradlew clean build
  1. Run the Application:
./gradlew bootRun

The application will start, and you can access it at http://localhost:8080.