A highly interoperable kotlin multiplatform assertion library
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()
}
}
}
dependencies {
implementation("tz.co.asoft:kommander-core:unspecified")
// - - - - - or - - - - -
implementation("tz.co.asoft:kommander-coroutines:unspecified")
}
val name: String? = null
expect(name).toBeNull()
val age: Int = 0
expect(age).toBeNonNull()
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()
}
}
The full api reference of the kommander can be found at https://asoft-ltd.github.io/kommander
There are multiple ways you can support this project
If you found it useful, just give it a star
You can help by submitting pull request to available open tickets on the issues section
This makes it easier to catch bugs and offer enhancements required
- andylamax - The author