Kommander

A highly interoperable kotlin multiplatform assertion library

Usage

Simple usage is to just let your commander expect something and let your IDE guide you in prompting what assertion you need to do with your expected assumption

package samples

import kommander.expect
import kommander.toBeGreaterThan
import kommander.toBeLessThan
import kotlin.test.Test

class PersonTest {
val person = Person(name = "John Doe", age = 30)

@Test
fun should_perform_basic_assertions() {
expect(person.name).toBe("John Doe")
expect(person.age).toBe(30)
}

@Test
fun should_perform_compound_assertion() {
expect(person.age) {
toBe(30)
toBeLessThan(50)
toBeGreaterThan(18)
toBeNonNull()
}
}
}

Setup: Gradle

dependencies {
implementation("tz.co.asoft:kommander-core:unspecified")
// - - - - - or - - - - -
implementation("tz.co.asoft:kommander-coroutines:unspecified")
}

Nullability

val name: String? = null
expect(name).toBeNull()

val age: Int = 0
expect(age).toBeNonNull()

Custom Assertions

You can create your custom assertions easily in kotlin as well

package samples

import kommander.Expect
import kommander.expect
import kommander.toBeGreaterThan
import kotlin.test.Test

class CustomAssertionsTest {
val person = Person(name = "Jane", age = 19)

fun Expect<Person>.toBeAnAdult() {
expect(value.age).toBeGreaterThan(18)
}

@Test
fun test_adulthood() {
expect(person).toBeAnAdult()
}
}

Api Reference

The full api reference of the kommander can be found at https://asoft-ltd.github.io/kommander

Support

There are multiple ways you can support this project

Star It

If you found it useful, just give it a star

Contribute

You can help by submitting pull request to available open tickets on the issues section

Report Issues

This makes it easier to catch bugs and offer enhancements required

Credits

All modules:

Link copied to clipboard
Link copied to clipboard