Skip to content
forked from jcornaz/kwik

Property-based testing library for Kotlin

License

Notifications You must be signed in to change notification settings

aleagnelli/kwik

 
 

Repository files navigation

Kwik

https://readthedocs.org/projects/kwik/badge/?version=latest https://img.shields.io/badge/dynamic/json.svg?color=blue&label=version&query=name&url=https%3A%2F%2Fapi.bintray.com%2Fpackages%2Fkwik%2Fstable%2Fkwik%2Fversions%2F_latest https://img.shields.io/badge/dynamic/json.svg?color=blue&label=preview&query=name&url=https%3A%2F%2Fapi.bintray.com%2Fpackages%2Fkwik%2Fpreview%2Fkwik%2Fversions%2F_latest

Property-based testing library for Kotlin.

Main features:

  • Test-engine agnostic
  • Multiplatform
  • No reflection
  • Configurable built-in generators
  • Easy way to create and combine generators

Planned features:

  • Shrinking

Find more information on https://kwik.readthedocs.io

Status

The project is incubating and its API is subject to changes.

Please give it a try and write a feed back in the issues or discuss on gitter.

How it looks like

class PlusOperatorTest {

    @Test
    fun isCommutative() = forAll { x: Int, y: Int ->
        x + y == y + x
    }

    @Test
    fun isAssociative() = forAll(iterations = 1000) { x: Int, y: Int, z: Int ->
        (x + y) + z == x + (y + z)
    }

    @Test
    fun zeroIsNeutral() = forAll(seed = -4567) { x: Int ->
        x + 0 == x
    }
}

For more information read the usage and look at the available generators

Motivation

Property based testing is great and very powerful. But despite the fact that many good libraries already exist, none of them fully fit my needs.

The known alternatives either:

  • Are bound to a specific test-engine
  • Can only be used in Java module (not in Kotlin multi-platform modules)
  • Relies on reflection, making them slower and make some errors detectable only at runtime
  • Do not allow enough freedom and safety to customize existing generators
  • Force the user to add unwanted dependencies in the classpath

Setup

Example of setup using gradle.

repositories {
    jcenter()
}

dependencies {
    testCompile("com.github.jcornaz.kwik:kwik-core-jvm:0.2.0")
}

Find more detailed information in the setup instructions.

Contribute

See how to contribute

About

Property-based testing library for Kotlin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 100.0%