Organizing and Running Your Tests

The most common way to structure Clojure projects is to have two source directories—one for source code and another for tests. Most Clojure tools automatically create and understand projects with this structure.

Tests are commonly stored in a namespace parallel to the namespace being tested, as in this example structure:

 
myproj
 
├── src
 
│ └── proj
 
│ └── util
 
│ └── string.clj
 
└── test
 
└── proj
 
└── util
 
└── test_string.clj

If we store our string utility functions in the proj.util.string namespace under the src/ directory, the associated tests are stored in a similarly named namespace under the sibling test/ directory. The tests will be available on the classpath when we run tests but will generally ...

Get Clojure Applied now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.