An extensive test suite is essential when maintaining a non-trivial code base over time. This series of episodes looks at various aspects of testing in Clojure, as well interesting libraries to add to your toolbox.
Generative testing, also called Property Based testing, is a powerful technique able to expose some of the most obscure bugs. You’ll learn how to create and compose generators, and how to define properties that together can verify many aspects of your code.
Learn how to use a headless web browser to test your application for feature completeness. You’ll also see how Component can be used to set up an isolated test environment, how to use fixtures and dynamic var bindings to share setup code between tests, and how to keep tests readable and concise by judicously pulling code into helper functions.
Learn how to run tests with Figwheel, PhantomJS, Node, doo, and Karma.
Running Clojure tests once they are written is pretty straightforward, but for ClojureScript there are a few more things to consider. Your code needs to be compiled first, and then needs to run on the JavaScript engine of your choice. In this episode you’ll learn how to set up a ClojureScript project from scratch using Figwheel, how to run tests from the REPL, how to create test runners for PhantomJS and Node, and how to use doo and Karma to run your tests on a wide variety of browsers simultaneously.
Testing libraries and frameworks are indispensable, but there’s no magic to how
they work. Through implementing your own mini testing framework, you’ll learn
how clojure.test
does things under the hood.
While the main plot demonstrates how to write a function test-first, you’ll also
meet several supporting characters, like preconditions, dynamic bindings, and
even a macro. Finally the mask comes off. It was clojure.test
all this time!