Clojure for Beginners: Clojure Testing with clojure.test — deftest, is, testing, from REPL to CI
Video: Clojure Testing with clojure.test — deftest, is, testing, from REPL to CI | Episode 22 by CelesteAI
Watch full page →Clojure Testing with clojure.test — deftest, is, testing, from REPL to CI
Tests you can run in seconds are tests you'll actually run. In this episode we pin down the `app.util` namespace from Episode 20 — `shout`, `slugify`, `wrap` — with real `clojure.test` assertions. Three `deftest` blocks, seven `is` assertions, and both ways to run them: from the REPL with `run-tests`, and from the command line with `clj -M:test`.
Test Code
(ns app.util-test
(:require [clojure.test :refer [deftest is testing]]
[app.util :as u]))
(deftest shout-test
(testing "uppercases and appends a bang"
(is (= "HI!" (u/shout "hi")))
(is (= "HELLO WORLD!" (u/shout "hello world")))))
(deftest slugify-test
(testing "lowercase, trim, replace spaces, strip punctuation"
(is (= "hello-world" (u/slugify "Hello World")))
(is (= "hello-world" (u/slugify " Hello, World! ")))
(is (= "the-little-schemer" (u/slugify "The Little Schemer")))))
(deftest wrap-test
(testing "wraps with the same character on both sides"
(is (= "*hi*" (u/wrap "*" "hi")))
(is (= "|a|" (u/wrap "|" "a")))))
Key Points
Watch the video above for a full walkthrough — every keystroke is shown so you can code along.
Student code: GitHub