Java Reference
In-Depth Information
Figure 6.1. Java tests in this chapter are from JUnit. The standard Groovy library includes a subclass of JUnit's
TestCase called GroovyTestCase , and its subclasses are useful as well. The Spock framework is a very
popular alternative testing API that includes a JUnit test runner. Groovy makes it easy to create mock objects
through library classes like Expando , MockFor , and StubFor .
6.1. Working with JUnit
The agile development community created JUnit ( http://junit.org ) as a great tool for auto-
mating tests. While other Java testing tools exist, JUnit has been so influential that nearly
every Java developer I encounter has either used it or heard of it. JUnit's success has
spawned an entire family of comparable tools for other languages (known collectively as
“xUnit”). JUnit is simple, easy to use, and ubiquitous in the Java world. As I'll show in this
chapter, the available Groovy tools also are easy to use and easy to learn, and some of them
are based directly on JUnit. [ 1 ]
1 Now known more commonly as “agile” development, because most Fortune 500 companies don't want to be asso-
ciated with “extreme” anything.
Adding JUnit to your projects (a review from chapter 5 )
JUnit is an open source project created by two of the founders of Extreme Programming, 1
Erich Gamma and Kent Beck. The JUnit library can be downloaded from the home site
( http://junit.org ), but it's built into most of the common IDEs, including Eclipse, NetBeans,
 
 
Search WWH ::




Custom Search