kuickcheck
kuickcheck copied to clipboard
A property based testing framework for Kotlin
= kuickcheck
image:https://app.wercker.com/status/ff9ea38222cd71c29bfa9062e2b7ac46/s[link="https://app.wercker.com/project/bykey/ff9ea38222cd71c29bfa9062e2b7ac46"]
KuickCheck is a property based testing framework for https://kotlinlang.org/[Kotlin] inspired by other property based testing frameworks, especially https://github.com/rickynils/scalacheck[scalacheck], https://pholser.github.io/junit-quickcheck/site/0.6/index.html[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 [source, xml]
.Gradle [source,groovy]
dependencies { testCompile 'org.mikeneck:kuickcheck' }
= Writing Test
Writing test is very easy.
- Create class or singleton object.
- Prepare your test data with
Generator(in the sample code it will be prepared bypositiveIntphrase) and pass it toforAllmethod. - Write the property for the data at
satisfyblock. - Give the name to the property as read-only field name.
- Annotate the property with
@Property.
Then KuickCheck will run check for the property 100 times as default.
.Sample Code [source, kotlin]
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 [source,groovy]
task runTest(type: JavaExec) { classpath sourceSets.test.runtimeClasspath main = 'org.mikeneck.kuickcheck.KuickCheck' standardOutput = System.out }
= License
http://www.apache.org/licenses/LICENSE-2.0[Apache2]