All Projects → from-source → kiwi

from-source / kiwi

Licence: MIT license
Fluent assertions for Kotlin

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to kiwi

Fluentassertions
A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit tests. Targets .NET Framework 4.7, .NET Core 2.1 and 3.0, as well as .NET Standard 2.0 and 2.1. Supports the unit test frameworks MSTest2, NUnit3, XUnit2, MSpec, and NSpec3.
Stars: ✭ 2,449 (+14305.88%)
Mutual labels:  assertions, fluent-assertions
fluentcheck
Fluent assertions for Python
Stars: ✭ 79 (+364.71%)
Mutual labels:  assertions, fluent-assertions
json matcher
Library for simplifying data verification in functional tests for your JSON-based APIs
Stars: ✭ 24 (+41.18%)
Mutual labels:  assertions
MultiplatformPlayground
Kotlin Multiplatform project in Jetpack Compose & SwiftUI with shared ViewModel layer and File upload
Stars: ✭ 72 (+323.53%)
Mutual labels:  kotlin-multiplatform
Scout
Scout is a kotlin multiplatform application that allows users to search and save games to lists to be browsed later.
Stars: ✭ 28 (+64.71%)
Mutual labels:  kotlin-multiplatform
KParser
Kotlin Multiplatform Arithmatic Parser
Stars: ✭ 32 (+88.24%)
Mutual labels:  kotlin-multiplatform
mobius.kt
Kotlin Multiplatform framework for managing state evolution and side-effects
Stars: ✭ 39 (+129.41%)
Mutual labels:  kotlin-multiplatform
D-KMP-sample
D-KMP Architecture official sample: it uses a shared KMP ViewModel and Navigation for Compose and SwiftUI apps.
Stars: ✭ 636 (+3641.18%)
Mutual labels:  kotlin-multiplatform
KMQTT
Embeddable and standalone Kotlin Multiplatform MQTT broker
Stars: ✭ 56 (+229.41%)
Mutual labels:  kotlin-multiplatform
StarWars
Minimal GraphQL based Jetpack Compose, Wear Compose and SwiftUI Kotlin Multiplatform sample (using StarWars endpoint - https://graphql.org/swapi-graphql)
Stars: ✭ 165 (+870.59%)
Mutual labels:  kotlin-multiplatform
CompleteKotlin
Gradle Plugin to enable auto-completion and symbol resolution for all Kotlin/Native platforms.
Stars: ✭ 236 (+1288.24%)
Mutual labels:  kotlin-multiplatform
LinuxCommandLibrary
1M+ downloads Linux reference app with basics, tips and formatted man pages
Stars: ✭ 333 (+1858.82%)
Mutual labels:  kotlin-multiplatform
trikot.patron
Kotlin Multiplatform Sample Project using Trikot libraries
Stars: ✭ 13 (-23.53%)
Mutual labels:  kotlin-multiplatform
zerocode-hello-world
Zerocode YAML and JSON based declarative steps hello world rest api testing example - soap, database
Stars: ✭ 18 (+5.88%)
Mutual labels:  assertions
tau
A Micro (1k lines of code) Unit Test Framework for C/C++
Stars: ✭ 121 (+611.76%)
Mutual labels:  assertions
kotlin-no-backend
Lista de empresas que utilizam Kotlin no Brasil.
Stars: ✭ 46 (+170.59%)
Mutual labels:  kotlin-multiplatform
superdeno
Super-agent driven library for testing Deno HTTP servers.
Stars: ✭ 119 (+600%)
Mutual labels:  assertions
serialization-parcelable
Android Parcelable support for the Kotlinx Serialization library.
Stars: ✭ 53 (+211.76%)
Mutual labels:  kotlin-multiplatform
kmm-production-sample
This is an open-source, mobile, cross-platform application built with Kotlin Multiplatform Mobile. It's a simple RSS reader, and you can download it from the App Store and Google Play. It's been designed to demonstrate how KMM can be used in real production projects.
Stars: ✭ 1,476 (+8582.35%)
Mutual labels:  kotlin-multiplatform
chords
A Kotlin multi-platform view library for displaying stringed instrument chord diagrams
Stars: ✭ 25 (+47.06%)
Mutual labels:  kotlin-multiplatform

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

Release

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

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

Collections

Kiwi supports List, Set and Map

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

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

Numbers

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

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

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

Dates

LocalDate and LocalDateTime

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

        date.should
               .beInLeapYear()
               .beInQ4()
               .beBefore(date.plusDays(1))
    }

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)


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

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

        animals.should
                .haveSize(4)
                .contain(flamingo)
                .beSorted { it.weight }
                .filtered { animal -> animal.mammal }
                .matchAny { animal -> animal.heavy() }

    }

JsonPath

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

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

        json.should
                .haveJsonPath("$.kiwi")
                .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

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

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

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

Build

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

    @Test
    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"
                }]
            }
        }"""

        json.should
                .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 the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].