Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
So far, we have been running our Groovy tests individually. For large systems, tests typically aren’t run individually but are grouped into test suites that are run together. JUnit has built-in facilities for working with suites. These facilities allow you to add individual test cases (and other nested suites) to test suites. JUnit’s test runners know about suites and run all the tests they contain. Unfortunately, these facilities require you to manually add all of your tests to a suite and assume you are using Java classes for your tests. We’ll look at ways of making life easier with Groovy.
Because grouping tests into suites is so important, numerous solutions have popped up in the Java world for automatically creating suites, but these too typically assume you are using Java classes. The good news is that because Groovy classes compile to Java classes, you don’t have to abandon any of your current practices for grouping tests—as long as you are willing to compile your Groovy files using groovyc first. The even better news is that there are solutions that allow you to work more naturally directly with your Groovy files.