views:

38

answers:

1

Is it possible to unit test addTo* functions in Grails ?

thanks for your help.

A: 

The documentation says in section 9.1:

In Grails you need to be particularity aware of the difference between unit and integration tests because in unit tests Grails does not inject any of the dynamic methods present during integration tests and at runtime.

You either have to use mockDomain(DomainClassName) in a unit test or write an integration test:

Grails decorates domain object with some Dynamic methods when the DomainClassGrailsPlugin gets setup(doWithDynamicMethods).

Colin Harrington