Reputation: 11
I have a controller written in grails where i have used name of a domain class to retrieve data from db. Now I want to test it using grails default test.
But it is returning a error:
java.lang.IllegalStateException: Either class [cre_service.AppPreferences] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.
Upvotes: 1
Views: 519
Reputation: 3932
Sounds like you need to Mock you domain class e.g.
import spock.lang.Specification
import grails.test.mixin.Mock
@Mock( [AppPreferences] )
class YourControllerClassSpec extends Specification {
...
Upvotes: 1