Kluent

Kluent is a “Fluent Assertions” library written specifically for Kotlin.

It uses the Infix-Notations and Extension Functions of Kotlin to provide a fluent wrapper around JUnit-Asserts and Mockito.

How to contribute

Contributors

Changelog

Platform Status MacOS / Linux Windows

Guide

Basic Assertions

Numerical Assertions

CharSequence Assertions

Collection Assertions

Exception handling

Mocking

java.time Assertions

FileSystem

Define own assertions

Using backticks

Every method that is included in Kluent also has a “backtick version”, to make it feel more like a describing sentence.

Some examples:

assertEquals

"hello" shouldBeEqualTo "hello" "hello".shouldBeEqualTo("hello") "hello" `should be equal to` "hello"

assertNotEquals

"hello" shouldNotBeEqualTo "world" "hello".shouldNotBeEqualTo("world") "hello" `should not be equal to` "world"

Collections

shouldBeEmpty shouldNotBeEmpty

CharSequence

shouldBeEmpty shouldNotBeEmpty shouldBeBlank shouldNotBeBlank

CharSequence?

shouldBeNullOrEmpty shouldNotBeNullOrEmpty shouldBeNullOrBlank shouldNotBeNullOrBlank

Nullables

shouldBeNull shouldNotBeNull

Boolean

shouldBeTrue shouldBeFalse shouldNotBeTrue shouldNotBeFalse

Chaining of assertions