ProductPromotion
Logo

Kotlin

made by https://0x3d.site

GitHub - MarkusAmshove/Kluent: Fluent Assertion-Library for Kotlin
Fluent Assertion-Library for Kotlin. Contribute to MarkusAmshove/Kluent development by creating an account on GitHub.
Visit Site

GitHub - MarkusAmshove/Kluent: Fluent Assertion-Library for Kotlin

GitHub - MarkusAmshove/Kluent: Fluent Assertion-Library for Kotlin

Kluent

Changelog Documentation Contributors Current version

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-Assertions.

How to contribute


Include it via gradle/maven

Kluent is hosted here at mavenCentral

Kluent-Android is hosted here at mavenCentral

Gradle

Replace {version} with the current version and chose one of the two artifacts, based on your target platform:

// Add jcenter as a repository for dependencies
repositories {
    mavenCentral()
}

dependencies {
    // for JVM:
    testImplementation 'org.amshove.kluent:kluent:{version}'

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

    // To get JUnit errors from kotlin.test, to e.g. enable diff windows in failure messages
    testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_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" shouldBeEqualTo "hello"

assertNotEquals

"hello" shouldNotBeEqualTo "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

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

assertNotEquals

"hello" `should not be equal to` "world"

Building Kluent

All projects of Kluent are built with Gradle

The default gradlew build will only build the common and jvm module, to keep the build times as small as possible.

If you plan to submit a pull request, it is also fine if you just make sure it builds and tests against common and jvm (which gradlew build will make sure of), because the rest of the heavy work will be done by Travis and AppVeyor. That way you can keep your machine free from NodeJS and Kotlin Native :-)

To build the Android library, pass the parameter ANDROID to Gradle. This will build the common and android artifacts. To pass the parameter, type:

gradlew build -PANDROID

To also build the JS module, pass JS:

gradlew build -PJS

To build native, pass:

gradlew build -PNATIVE

In these cases, the JVM module will also be built, because it is our primary target and everything should pass on the JVM. To skip the JVM build, e.g. for testing only against Native or JS, pass SKIPVM:

gradlew build -PJS -PNATIVE -PSKIPJVM

This command will build common, js, native, but not jvm.

Where to put new features

If you plan to add a feature (e.g. an Assertion), it would be nice to first try adding it to the common module, as it would then be available to all platforms. If it uses specific APIs, like classes from the Java standard library, then it needs to go to the jvm module.

If you're unsure where to put a feature, or if you want to put something in the common module which needs platform specific implementations, you can have a look here (platformIsDigit or platformClassName) where a function in the common module calls a so called expect function, which is defined here in the common module and has specific JVM , JS and Native implementation.

If you're still unsure how to make something platform independent, we can have a look together inside the PR :-)

Attribution

Parts of the assertSoftly feature are based upon the great work of Kotest under the Apache 2.0 License.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory