Chapter 4Testing

There are few topics in the software development world more polarizing than testing. Almost everybody agrees that testing software is a necessary activity, and to develop software professionally without testing would be irresponsible. In some communities such as the Ruby on Rails community, they advocate test driven development, or TDD, and due to their heavy focus on testing they have pioneered and inspired many testing frameworks and techniques.

Some people may get the impression that many in the Clojure community are not serious about testing, or even flat out anti-testing; however, nothing could be further from the truth. Many of the maintainers and developers in the community are very much in favor of testing, and they feel it would be irresponsible to deliver software without quality tests proving that your software does as it intends.

No amount of testing can make up for not being able to reason about your code. Having tests alone doesn't mean that you are safe from defects and able to confidently make changes to your code. You must first have a deep understanding of what constitutes a good test for your particular problem.

This chapter covers the basics of testing Clojure code using the clojure.test framework. The chapter also details examples that are more difficult and investigates some ...

Get Professional Clojure 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.