Search⌘ K
AI Features

Setting Up Integration Tests

Explore how to set up integration tests for Scala HTTP services by configuring test databases, managing logging outputs, and initializing Akka-HTTP components. Understand creating a reusable base test class that handles service startup, database migration, and proper resource cleanup for effective integration testing.

Configuration file for integration tests

First, we need to configure our test database because we do not want to accidentally wipe out our production database. For our case, we leave everything as is and change the database name.

Scala
api {
host = "localhost"
port = 49152
}
database {
profile = "slick.jdbc.PostgresProfile$"
db {
connectionPool = "HikariCP"
dataSourceClass = "org.postgresql.ds.PGSimpleDataSource"
properties {
serverName = "localhost"
portNumber = "5432"
databaseName = "impure_test"
user = "impure"
password = "secret"
}
numThreads = 10
}
}

Logging configuration for integration tests

Another thing we should do is provide a test configuration for our logging framework. We use the logback library. Slick will produce a lot of logging output ...