Git Product home page Git Product logo

kluent's Introduction

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


Include it via gradle/maven

Kluent is hosted here at jcenter

Kluent-Android is hosted here at jcenter

Gradle

Replace {version} with the current version

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

    // for Android:
    testImplementation 'org.amshove.kluent:kluent-android:{version}'
}

Maven

Replace {version} with the current version

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

Examples

More examples can be seen on the Site or in the 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"

kluent's People

Contributors

markusamshove avatar andreasvolkmann avatar mrobakowski avatar adeconinck-zenika avatar tgirard12 avatar vjames19 avatar guenhter avatar gaumala avatar okkero avatar cketti avatar

Watchers

James Cloos avatar Greg Woodfill avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.