Clojure spec Screencast: Testing

clojure-logo-120b.png

Clojure spec defines specifications for both data and functions. In addition to validity checking, specs can generate random samples of the data they specify. This capability enables an alternative to unit testing known as generative, or property-based, testing.

The "check" function automatically generates a large number of example inputs to a function and checks that the invocation of the function satisfies its specification. A complementary function "instrument" verifies that calls to a function satisfy the function's specification. In this screencast, Stuart Halloway demonstrates how to use both "check" and "instrument" to automatically leverage specs to better test your code.

Find out how Cognitect can help you get the most out of Clojure, including bringing your team up to speed on tools and practices, and introducing the latest additions to the ecosystem.