Programming language: Kotlin
License: MIT License
Tags: Tests    

kiwi alternatives and similar libraries

Based on the "Tests" category.
Alternatively, view kiwi alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of kiwi or a related project?

Add another 'Tests' Library


Kiwi: Fluent assertions for Kotlin projects

License Build Status Awesome Kotlin Badge

Kiwi is multiplatform projects written in pure Kotlin. Except testing it does not use external dependencies


Kiwi is available in SNAPSHOT repository for now

repositories {
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots"

dependencies {
    testImplementation 'org.fromsource:kiwi-core-jvm:0.0.2-SNAPSHOT'

Kiwi, Hello World!

Below snippet demonstrates usage of Kiwi assertions for standard type like String

    fun `should say hallo to kiwi()` {
        "Kiwi, Hello World!".should startWith "Kiwi" contain "Hello" endWith "!"


Kiwi supports List, Set and Map

    fun `should combine operator in infix chain`() {
        val animals = listOf("kiwi", "hedgehog", "flamingo", "humpback")

        animals.should haveSize 4 contain "humpback" have1st "kiwi"


as well as Byte, Short, Int, Long, Float, Double and JVM based numbers like BigDecimal, BigNumber

    fun `should check if numer is prime`() {
        val number = 7

                .match { number -> (2 until number).all { number % it != 0} }


LocalDate and LocalDateTime

    fun `should check if date meets some conditions`() {
        val date = LocalDate.of(2020, 11, 14)


Custom type

... even custom types are supported

    data class Animal(val name: String, val weight: Int, val mammal: Boolean) {
       fun heavy(): Boolean = weight > 10

    val kiwi     = Animal(name = "kiwi", weight = 1, mammal = true)
    val hedgehog = Animal(name = "hedgehog", weight = 2, mammal = true)
    val flamingo = Animal(name = "flamingo", weight = 5, mammal = false)
    val humpback = Animal(name = "humpback", weight = 5000, mammal = true)

    fun `should apply collection operators for list of custom object`() {

        val animals = listOf(kiwi, hedgehog, flamingo, humpback)

                .beSorted { it.weight }
                .filtered { animal -> animal.mammal }
                .matchAny { animal -> animal.heavy() }



If you need json path Kiwi will work too. See Roadmap & Future for more details

    fun `should select json paths for json string`() {
        val json = """{
            "kiwi": "kotlin assertion library",
            "github": {
                "developers": ["john", "ben"]

                .haveJsonPath("$.kiwi", """"kotlin assertion library"""")
                .haveJsonPath("$..developers", """["john", "ben"]""")
                .haveJsonPath("$..developers[0]", """"john"""")

Mix of the operators

Last but not least you can mix all together Different types of operators e.g. Collection, String, Numbers can be used fluently

    fun `should mix different types of operators`() {

        val animals = listOf(kiwi, hedgehog, flamingo, humpback)

                .contain(hedgehog)                              // Collection operator
                .last().name                                    // extract
                .match(Regex("[a-z]+"))                         // String operator


Run command below

$ git clone [email protected]/from-source/kiwi.git
$ cd kiwi/
$ ./gradlew clean build

Roadmap & Future

JsonPath evaluation - in progress

Take a look at the JsonPathAcceptanceTest to see which json path selectors are available

    fun `should select first book in the store`() {
        val json =  """{ 
            "store": {
                "details": {
                    "name": "Books & Books"
                "books": [
                    "category": "science",
                    "author": "Douglas Hofstadter",
                    "title": "I Am a Strange Loop",
                    "price": 8.95
                    "category": "science fiction",
                    "author": "Stanislaw Lem",
                    "title": "Solaris",
                    "isbn": "978-0156027601",
                    "price": 10.99,
                    "details": "Published in 1961"

                .haveJsonPath("$.store.details")                                // check if path exists
                .haveJsonPath("$..books[1].category", "science fiction")        // check value of path
                .haveJsonPath("$..books[0]", """{                              
                    "category": "science",
                    "author": "Douglas Hofstadter",
                    "title": "I Am a Strange Loop",
                    "price": 8.95


Support for more Kotlin types

Sponsored by JetBrains

*Note that all licence references and agreements mentioned in the kiwi README section above are relevant to that project's source code only.