Practicalli Clojure 5 - Writing tests with clojure.test
Channel: Community Developer
Date: 2018-12-01

Discover more videos and books and motivate me to create more at https://practicalli.github.io/#support

This week we will look at Test Driven Development and Clojure.

The clojure.test library is part of Clojure and is the simplest way to start with TDD and Clojure.  We will take a small challenge and solve it by first writing a failing test, then writing some code to make the test pass, then refactor the code if necessary.

We will start by creating a new project on the command line with Leiningen, which creates parallel source and test branches.

lein new my-project

Open the source code file from the project (`SPC f f`) and start the REPL - `, '` or `M-RET`.

Toggle between source code and test code with `SPC p a`.  Or open the other in a new window using `SPC p f`, highlight the filename and use `C-c o` to open in new window. 

Run all tests using `, t a` or `M-RET t a`.

To automate running of tests, toggle cider-auto-test-mode using `, T t` and then evaluate either source or test buffer using `, e b` and tests will run for that namespace

All videos from the Practicalli study guide are available on the playlist
https://www.youtube.com/playlist?list=PLpr9V-R8ZxiDjyU7cQYWOEFBDR1t7t0wv

Subscribe to the Practicalli channel for all new videos
https://www.youtube.com/channel/UCLsiVY-kWVH1EqgEtZiREJw

Discuss these solutions on the #practicalli channel of the Clojurians Slack community.  http://clojurians.net/ has a self-sign-up form if you do not already have a free account for Clojurians Slack community.