Book Image

Clojure Web Development Essentials

By : Ryan Baldwin
Book Image

Clojure Web Development Essentials

By: Ryan Baldwin

Overview of this book

Table of Contents (19 chapters)
Clojure Web Development Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Writing and running our first test


We're going to create a few tests for the validators we created in Chapter 5, Handling Form Input. In our directory structure, we have the src and test directories. I'll give you two seconds to determine under which directory our tests should go… got it? If you said src, then I have failed to achieve the modest task that was my charge. We will be storing our tests in the test directory using the following steps:

  1. Create a directory in the /test/hisptr/test directory called validators.

  2. Create a file in the /text/hipstr/test/validators directory called user_validator_test.clj.

  3. In user_validator_test.clj, define our namespace and include the clojure.test namespace and the namespace we wish to test—in our case, the hipstr.validators.user-validator namespace:

    (ns hipstr.test.validators.user-validator-test
      (:require [hipstr.validators.user-validator :as uv])
      (:use clojure.test))
  4. Next, let's add a test that ensures only one error message is returned in the errors...