Scala Example: TestContainers and MUnit

Scala Example: TestContainers and MUnit

Created: <2022-07-16 Sat>

Abstract

Simple example of an Integration test using:

Beware the fact that with MUnit the names of the traits might change compared to Scalatest.

Content

Dependencies

  • Add dependencies to the project and submodules
  • Add the it scope to the libraries
  • Add IntegrationTest configuration extending Test configuration
  • Add Default.itSettings to your project and submodules settings

Case 1: Single Test Container

Most simple case, where you declare a single container in your test to use. In the following example a PostgreSQLContainer is shown.

Case 2: Docker-Compose

Here there's flyway as well to run the migrations. Not necessary for this example.

Scala Code
  • DockerComposeContainer Definition
  • Simple MUnit Spec file

Share Buttons