The Grails testing framework enables you to define a series of tests, both at the Unit and Integration level, to run the suite with results reporting, and to supply test data. This page describes how to integrate Automated Business Logic into the Grails testing framework under STS (Spring Source Tool Suite).
Just as you must configure Grails to engage business logic when running applications, you must also engage it when running tests. You do so using the same approach, shown below:
Grails provides a very helpful mechanism for creating test data, refreshed for each run. Such data is created using normal Gorm API's as shown below. Since business logic hooks into Gorm/Hibernate events, this data is subjected to your rules so will conform to your constraint and derivation rules. This relieves you of a great deal of tedium in creating correct test data, or debugging logic based on bad existing data.
Create tests for your domain objects as Integration tests, so you have full access to the framework, test data bootstrapping, and so forth. Salient points regarding the test shown below:
Grails produces a report like this, accessed via the hyperlink in the console:
There is still a benign stacktrace run the Integration test in the TestApp.class: