Chapter 17. Unit testing with Groovy

 

This chapter covers

  • Unit testing Groovy and Java code
  • Incorporating code coverage tools
  • Integrating IDEs
  • Testing with Spock
  • Automating the build process

The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong, it usually turns out to be impossible to get at or repair.

Douglas Adams

Developer unit testing has become a de facto standard in the Java community.[1] The confidence and structure that JUnit[2] and other testing frameworks bring to the development process are almost revolutionary. To those of us who were actively developing Java applications in the latter years of the 20th century, automated unit testing was almost unheard of. Yes, we wrote tests, but they were hardly automated or even a part of a standard build!

1 See Kevin Tate, Sustainable Software Development: An Agile Perspective (Addison Wesley Professional, 2005) and Greg Smith and Ahmed Sidky, Becoming Agile (Manning, 2009).

2 See Petar Tahchiev, et al., JUnit in Action, 2nd Ed. (Manning, 2010); J. B. Rainsberger, JUnit Recipes (Manning, 2004), and www.junit.org for more information.

17.1. Getting started

17.2. Unit testing Groovy code

17.3. Unit testing Java code

17.4. Organizing your tests

17.5. Advanced testing techniques

17.6. IDE integration

17.7. Testing with the Spock framework

17.8. Build automation

17.9. Summary

sitemap