Example-Based Tests with clojure.test

Example-based testing is the process of exercising bits of code by passing known inputs (the examples) and checking that the outputs match expected values. Most Clojure programs are composed primarily of immutable data and pure functions, which are particularly amenable to example-based tests, because no messy mutable state leaks into or out of the code being tested. Example-based testing is most useful when working in the small, at the level of single functions or small groups of functions. This style of testing is most commonly exemplified by the xUnit libraries available in most languages.

clojure.test is a library included in the Clojure standard library that provides facilities comparable to JUnit or ...

Get Clojure Applied now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.