Giter Site home page Giter Site logo

schema-generators's Introduction

A Clojure(Script) library for data generation and generative testing with https://github.com/plumatic/schema and clojure.test.check.

Clojars Project

Circle CI

This is an alpha release. The API and organizational structure are subject to change. Comments and contributions are much appreciated.

--

This library provides two experimental forms of automatic test data generation from schemas.

(require '[schema-generators.complete :as c] '[schema-generators.generators :as g])

(g/sample 3 Animal)
;; => ({:name "", :barks? false, :type :dog}
;;     {:name "", :claws? false, :type :cat}
;;     {:name "\"|", :claws? false, :type :cat})

(g/generate Tree)
;; => {:value -8N, :children [{:value 5, :children [{:value -2N, :children []}]}
;;                            {:value -2, :children []}]}

(c/complete {:type :dog} Animal)
;; => {:name "nL@", :barks? false, :type :dog}

The schema-generators.generators namespace can compile Schemas into clojure.test.check generators. All of the built-in schemas are supported out of the box, and it is easy to extend to add new types or customize generation on a per-type basis. See schema-generators.generators-test for some more complex examples.

Moreover, the schema-generators.complete namespace can build on generation to allow "completion" of partial data. Whereas generators and clojure.test.check are very useful tools for abstract property testing, completers are useful when we want to test the behavior of a function on a specific complex data structure, where only some parts of the data structure are relevant for the function under test. Completion supports all of the extensibility of generators, plus the ability to provide coercions to create very succinct helpers for test data generation. See schema-generators.complete-test for examples.

Testing

Community

Please feel free to join the Plumbing mailing list to ask questions or discuss how you're using Schema.

We welcome contributions in the form of bug reports and pull requests; please see CONTRIBUTING.md in the repo root for guidelines.

Supported Clojure versions

Schema-generators are currently supported on Clojure 1.7 and 1.8 and the latest version of ClojureScript.

License

Distributed under the Eclipse Public License, the same as Clojure.

schema-generators's People

Contributors

gfredericks avatar w01fe avatar milt avatar philomates avatar benalbrecht avatar

Watchers

James Cloos 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.