Skip to content

zamesilyasa/Kluent

 
 

Repository files navigation

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 the JUnit-Asserts and Mockito.

Download Build Status


Examples

More examples can be seen in the Wiki or tests.

assertEquals

"hello" shouldEqual "hello"

assertNotEquals

"hello" shouldNotEqual "world"

Assert that an Array/Iterable contains something

val alice = Person("Alice", "Bob")
val jon = Person("Jon", "Doe")
val list = listOf(alice, jon)
list shouldContain jon

Stubbing

val stub = mock(Database::class)
val bob = Person("Bob", "Guy")
When calling stub.getPerson() itReturns bob

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" `should equal` "hello"

assertNotEquals

"hello" `should not equal` "world"

Include it via gradle/maven

Kluent is hosted in jCenter

Gradle

dependencies {
    testCompile 'org.amshove.kluent:kluent:1.6'
}

Maven

<dependency>
    <groupId>org.amshove.kluent</groupId>
    <artifactId>kluent</artifactId>
    <version>1.6</version>
    <type>pom</type>
</dependency>

About

Fluent Assertion-Library for Kotlin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 100.0%