GithubHelp home page GithubHelp logo

test.generative's Introduction

clojure.test.generative

Generative test runner.

Releases and Dependency Information

Latest stable release: 0.5.2

Leiningen dependency information:

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

Maven dependency information:

<dependency>
  <groupId>org.clojure</groupId>
  <artifactId>test.generative</artifactId>
  <version>0.5.2</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 also create the underlying test data structures directly, marking vars with :clojure.test.generative/specs so they are picked up by the runner. This can be useful e.g. to model relationships between input parameters, or to specify a finite list of special cases. The example below specifies five specific one-argument arg lists:

(def ^::tgen/specs
  inc'-doesnt-overflow-specs
  [{:test 'clojure.test.math-test/inc'-doesnt-overflow
    :input-gen #(map vector [Long/MIN_VALUE -1 0 1 Long/MAX_VALUE])}])

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.

test.generative's People

Contributors

stuarthalloway avatar puredanger avatar bpsm avatar seancorfield avatar abedra avatar fogus avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.