Database Testing with Testcontainers and Kotlin Exposed ORM

This page summarizes the projects mentioned and recommended in the original post on

Our great sponsors
  • Appwrite - The open-source backend cloud platform
  • Onboard AI - Learn any GitHub repo in 59 seconds
  • InfluxDB - Collect and Analyze Billions of Data Points in Real Time
  • Exposed

    Kotlin SQL Framework

    object TestDatabase { private val mySQLContainer: MySQLContainer = MySQLContainer("mysql:8.0.26").apply { withDatabaseName("test-db") withUsername("test-user") withPassword("test-password") start() // Start the container } init { val config = HikariConfig().apply { jdbcUrl = mySQLContainer.jdbcUrl username = mySQLContainer.username password = mySQLContainer.password driverClassName = "com.mysql.cj.jdbc.Driver" maximumPoolSize = 10 } val dataSource = HikariDataSource(config) // This doesn't connect to the database but provides a descriptor for future use // In the main app, we would do this on system start up // Database.connect(dataSource) // Create the schema transaction { SchemaUtils.create(Users) } } }

  • Testcontainers

    Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.

    In this article, we will explore how to use Testcontainers and Exposed, a lightweight ORM framework for Kotlin, to create a controlled environment for testing MySQL Database operations.

  • Appwrite

    Appwrite - The open-source backend cloud platform. Add Auth, Databases, Functions, and Storage to your product and build any application at any scale while using your preferred coding languages and tools.

  • til

    You can find the complete source code for this tutorial on GitHub

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts