SkillAgentSearch skills...

Atrium

A multiplatform expectation library for Kotlin

Install / Use

/learn @robstoll/Atrium

README

<!-- for main -->

Download EUPL atrium @ kotlinlang.slack.com Quality Assurance Coverage Newcomers Welcome

<!-- for a specific release --> <!-- [![Download](https://img.shields.io/badge/Download-1.2.0-%23007ec6)](https://central.sonatype.com/artifact/ch.tutteli.atrium/atrium-fluent/1.2.0) [![EUPL](https://img.shields.io/badge/%E2%9A%96-EUPL%201.2-%230b45a6)](https://joinup.ec.europa.eu/collection/eupl/eupl-text-11-12 "License") [![atrium @ kotlinlang.slack.com](https://img.shields.io/static/v1?label=kotlinlang&message=atrium&color=blue&logo=slack)](https://kotlinlang.slack.com/messages/C887ZKGCQ "See invitation link under section FAQ") [![Newcomers Welcome](https://img.shields.io/badge/%F0%9F%91%8B-Newcomers%20Welcome-blueviolet)](https://github.com/robstoll/atrium/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22 "Ask in slack for help") -->

<img src="https://raw.githubusercontent.com/robstoll/atrium/gh-pages/images/logo.svg?sanitize=true" alt="Atrium" title="Atrium"/>

Atrium is an open-source multiplatform expectation/assertion library for Kotlin with support for JVM, JS and Android. It is designed to support multiple APIs, focuses on helping developers to understand what went wrong and prevents common pitfalls. The project was inspired by AssertJ at first but moved on and provides now more flexibility, features and hints to its users (so to you 😉).

Atrium is designed to be extensible as well as configurable and allows you to extend it with your own expectation functions, customise reporting or even replace core components with your own implementation easily.

See Examples below to get a feel for how you could benefit from Atrium.


❗ You are taking a sneak peek at the next version. It could be that some features you find on this page are not released yet.
Please have a look at the README of the corresponding release/git tag. Latest version: README of v1.2.0.


Table of Contents

Installation

Atrium is published to mavenCentral. It has the following minimum requirement:

  • Kotlin: 1.4
  • JVM: 11
  • JS: IR-Backend (LEGACY support was dropped with Atrium 1.2.0)

In case you use Kotlin 1.5 or newer, then regardless of the target platform, you can use the following group and artifactId

build.gradle.kts:

repositories {
    mavenCentral()
}
dependencies {
    testImplementation("ch.tutteli.atrium:atrium-fluent:1.2.0")
}

And in case of an MPP project accordingly:

repositories {
    mavenCentral()
}
kotlin {
    sourceSets {
        val commonTest by getting {
            implementation("ch.tutteli.atrium:atrium-fluent:1.2.0")
        }
        // no need to add it to specific targets such as jvmTest, is done automatically starting with Kotlin 1.5
    }
}

Exchange fluent with infix depending on your taste (see API styles for more information).

That is all, you are all set. Jump to Examples which shows how to use Atrium.

<a name="installation-prior-to-kotlin-1.5"></a>

<details> <summary>I use a version prior to Kotlin 1.5</summary>

In case you use a version prior to Kotlin 1.5, then use the following depending on the target platform:

  • common: atrium-fluent
  • jvm: atrium-fluent-jvm
  • android: atrium-fluent-jvm
  • js: atrium-fluent-js
</details>

I have other problems: please take a look at the Sample Projects for further guidance.

Sample Projects

Have a look into the samples folder, it currently contains sample projects for

Are you using a different runner? A PR would be appreciated 😊.

Examples

We are using the API provided by the bundle module atrium-fluent in the following examples. It provides a pure fluent API for the JVM platform. Have a look at apis/differences.md to see how the infix API looks like, how they differ respectively.

Your First Expectation

See also AnyExpectationSamples for further examples.

We start off with a simple example:

<ex-first>
import ch.tutteli.atrium.api.fluent.en_GB.*
import ch.tutteli.atrium.api.verbs.expect

val x = 10
expect(x).toEqual(9)

<sub>Example</sub><sub>Output</sub> <a name="ex-first"></a>

I expected subject: 10        (kotlin.Int <1234789>)
◆ to equal: 9        (kotlin.Int <1234789>)
</ex-first>

The statement can be read as "I expect x to equal nine" where an equality check is used (for an identity check, you would have to use toBeTheSameInstace). Since this is false, an AssertionError is thrown with a corresponding message as shown in the Output where on the first line the actual subject (10 in the above example) is shown and on following lines which start with, ◆ ... (here only

Related Skills

View on GitHub
GitHub Stars622
CategoryDevelopment
Updated4h ago
Forks231

Languages

Kotlin

Security Score

100/100

Audited on Mar 31, 2026

No findings