Skip to content

mike-neck/kuickcheck

Repository files navigation

kuickcheck

s

KuickCheck is a property based testing framework for Kotlin inspired by other property based testing frameworks, especially scalacheck, junit-quickcheck.KuickCheck has no external dependencies other than Kotlin runtime and Kotlin reflection.

Download

KuickCheck is published to Maven Central, so you can get the latest version by adding the dependency to pom.xml or build.gradle.

Currently KuickCheck is not published, so download or clone this project to your machine.

Maven
<dependency>
  <groupId>org.mikeneck</groupId>
  <artifactId>kuickcheck</artifactId>
</dependency>
Gradle
dependencies {
  testCompile 'org.mikeneck:kuickcheck'
}

Writing Test

Writing test is very easy.

  1. Create class or singleton object.

  2. Prepare your test data with Generator(in the sample code it will be prepared by positiveInt phrase) and pass it to forAll method.

  3. Write the property for the data at satisfy block.

  4. Give the name to the property as read-only field name.

  5. Annotate the property with @Property.

Then KuickCheck will run check for the property 100 times as default.

Sample Code
object GettingStarted {

  @Property
  val positiveNumberIsMoreThan0 =
      forAll(positiveInt).satisfy{ it > 0 }
}

Running Tests

KuickCheck jar contains main function at org.mikeneck.kuickcheck.KuickCheck class. So you can run tests via java -jar command.

With Gradle

Add a new task to run KuickCheck test by JavaExec task.

Running Tests
task runTest(type: JavaExec) {
  classpath sourceSets.test.runtimeClasspath
  main = 'org.mikeneck.kuickcheck.KuickCheck'
  standardOutput = System.out
}

License

Releases

No releases published

Packages

No packages published

Languages