Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Clojure HTML

This branch is 15 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
docs
examples
src
.gitignore
README.md
data-model.org
epl.html
pom.xml

README.md

clojure.test.generative

Generative test runner.

Releases and Dependency Information

Latest stable release: 0.4.0

Leiningen dependency information:

[org.clojure/test.generative "0.4.0"]

Maven dependency information:

<dependency>
  <groupId>org.clojure</groupId>
  <artifactId>test.generative</artifactId>
  <version>0.4.0</version>
</dependency>

Example Usages

A defspec consists of a name, a function to be tested, an input spec, and a validator:

(defspec integers-closed-over-addition
  (fn [a b] (+' a b))                    ;; input fn
  [^long a ^long b]                     ;; input spec
  (assert (integer? %)))                ;; 0 or more validator forms

To generate test data, see the fns in the generators namespace. Note that these functions shadow a bunch of clojure.core names.

Running Interactively During Development

Specify the number of threads, the number of msec, and one or more vars to test:

(runner/run 2 1000 #'my/test-var)

Running in a CI environment

Wire your runner to call runner/-main with a list of directories where tests can be found. You can see bin/test.clj for an example.

You can use the following system properties to control the intensity of your test

Java PropertyInterpretation
clojure.test.generative.threadsNumber of concurrent threads
clojure.test.generative.msecDesired test run duration

Developer Information

Related Projects

  • ClojureCheck adds property based testing to clojure.test following the lines of QuickCheck for Haskell.

  • simple-check is a Clojure property-based testing tool inspired by QuickCheck.

Copyright and License

Copyright (c) 2012 Rich Hickey. All rights reserved. The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound bythe terms of this license. You must not remove this notice, or any other, from this software.

Something went wrong with that request. Please try again.