Java Reference
In-Depth Information
project that you can use as a basis for your project. Spock is built with Gradle, which con-
figures all the dependencies, and can plug into other APIs like Spring. See the docs and
APIs for details. [ 26 ]
26 See also the Manning book Spock in Action , by Ken Sipe, coming soon.
6.5. Summary
This chapter covered a lot of ground in the testing arena. Groovy brings a simple assert
statement into play that can be used for scripts and includes the GroovyTestCase class
that extends JUnit's capabilities. When it comes to managing dependencies, you can build
a stub implementation of an interface using closures, and you can build a more complete
stub using the Expando class.
Groovy also has the StubFor and MockFor classes, which can be used to test interac-
tions. They can even create mock objects for classes that are instantiated as local variables,
which is pretty amazing.
Finally, if you're willing to add an additional library, the Spock testing framework provides
a simple yet versatile API that still runs on your existing JUnit-based infrastructure. It also
has its own mock abilities and integrates with other libraries, like Spring and Tapestry.
Adding Groovy also adds a wide variety of options for testing Java and mixed Java/Groovy
projects. Hopefully the techniques in this chapter will help you decide where you can get
the most benefit from them.
 
Search WWH ::




Custom Search