Database Testing with Testcontainers and Kotlin Exposed ORM

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

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • 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 // https://github.com/JetBrains/Exposed/wiki/Database-and-DataSource 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.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • 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