Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

8.4. Summary

In this chapter, we looked at test-driven development in Clojure. As you saw, TDD in a language such as Clojure, can work as well as it does in other dynamic languages. In fact, when combined with the REPL, it gets an additional boost of productivity. You can write a failing unit test and try out various implementation ideas at the REPL. When it’s clear what approach to take, it’s easy to write the code to pass the test. Similarly, it’s easy to test implementations quickly at the REPL and then to copy the code over to the test files to add additional assertions and tests.

You then wrote a simple framework to stub functions, and then you added functionality to mock functions and verify the calls made to them. Clojure made it extremely easy—and the complete code for this clocked in at fewer than thirty lines of code. Although it probably didn’t satisfy every requirement from a stubbing and mocking library, it served our purposes well and it can be used as the basis for something more complex. It certainly showed how easily, seemingly complex things can be implemented in Clojure.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint