Grails 1.1 Testing – Unit, Integration & Functional
Last Friday I gave a presentation to the team here at 2Paths on the testing capabilities in Grails 1.1.
As you Grails die-hards know, Grails 1.1 introduced the new GrailsUnitTestCase class which is a very useful extension of GroovyTestCase with support for mocking the dynamic properties and methods that Grails injects into various types of classes (domain, controller & taglibs). Getting the team up to speed on this change was the original purpose of the presentation, but I decided to expand it to cover the full spectrum of testing capabilities in Grails 1.1 for those who might not have much exposure to it previously (including me!)
The presentation covered:
- the benefits & drawbacks of each type of testing: unit testing, integration testing, functional testing.
- details on the new GrailsUnitTestCase and it’s extensions (ControllerUnitTestCase and TagLibUnitTestCase)
- a few “gotchas” – such as using mockDomain with inheritance hierarchies
- WebTest goodness – test organization & re-use, Groovy step, passing params between Groovy & WebTest contexts, a little dive into using HtmlUnit to test AJAX
- general recommendations for what types of tests to create for each artifact (domain classes, controllers, services, etc)
Here’s a link to the presentation on SlideShare.net (where you can view it online or download it):
Happy testing!
Dave
Tags: antbuilder, controllerunittestcase, functional test, functional testing, Grails, grails 1.1, grails testing, grailsunittestcase, groovy, groovytestcase, htmlunit, integration test, integration testing, mockdomain, unit test, unit testing
