Friday, January 30, 2009

Grails Testing Tip

I had always wondered how to run individual types of tests in Grails. In order words I wanted to be able to run unit tests only or integration tests only. I did some digging in the TestApp.groovy script that ships with Grails and found that all you needed to do was specify it as an option on the command line.

grails test-app -unit
or
grails test-app -integration

This works as far as I know with Grails 1.0.3 not sure of 1.0.4 and 1.1-betas but I assume they won't be decommissioning this feature in a while since it is important. 
Never really got individual tests working though, as I have been unable to find anywhere that says how to run an individual test class.

Pointers to this will be appreciated.

In the coming days, I'll say something about mocking in Groovy using the 'as' feature.