This page last changed on Feb 28, 2006 by glaforge.

Unit testing

Creating & Running a test suite

To create a test suite run the "grails create-test-suite" target or just create a new class in "%PROJECT_HOME%\grails-test" that extends GroovyTestCase and ends with "Tests".

For more info on how to write unit tests using Groovy see the section on Unit Testing on the main Groovy website.

Below is an example of a test suite that tests the validate method on a domain class:

class BookTests {

    def testValid() {
        def b = new Book(title:"Groovy in Action", author:"Dierk Koenig")

        assert b.validate()
    }
}

To run the test suite run the command "grails test-app"

Document generated by Confluence on Mar 29, 2006 08:46