Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 bin
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 data-model.org
Octocat-spinner-32 epl.html initial commit April 23, 2011
Octocat-spinner-32 pom.xml
README.md

clojure.test.generative

Test data generation and execution harness. Very early days. This API will change. You have been warned.

Releases and Dependency Information

Latest stable release: 0.1.4

Leiningen dependency information:

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

Maven dependency information:

<dependency>
  <groupId>org.clojure</groupId>
  <artifactId>test.generative</artifactId>
  <version>0.1.4</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.

You can run clojure.test and clojure.test.generative tests together from the c.t.g. runner:

(require '[clojure.test.generative.runner :as runner])
(runner/-main "src/test/clojure" "src/examples/clojure")

Assertion support is currently minimal. There is an is macro, similar to clojure.test's, that provides rudimentaty contextual reporting. You can also use plain assertions, or clojure.test validation forms such as is and are, or any other forms that throw exception on failure. No contextual reporting for these yet.

You can configure the runner with Java system properties:

Java Property Interpretation
clojure.test.generative.threads Number of concurrent threads
clojure.test.generative.msec Desired test run duration
clojure.test.generative.handlers Comma-delimited list of handlers

The default handler prints test run to stdout, but others could e.g. put test events in a database.

Developer Information

Change Log

  • Release 0.1.5 (in development)
    • Can now run tests under clojure.test
    • Tests produce data events that can be consumed by arbitrary reporting tools
    • Example reporting integration with logback.
    • Added is macro with more detailed reporting than clojure.test/is
    • Removed collection based input generators. Input generators must be fns.
    • Removed duplicate input check. Tests can be called multiple times with same input.
  • Release 0.1.4 on 2012.01.03
    • Initial version

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.