Ajith Baskaran
Ajith Baskaran

Reputation: 11

When using a domain class in Controller it is returning a error when testing that controller is done

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

Answers (1)

Mike W
Mike W

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

Related Questions