0

나는 도메인 클래스의 이름을 사용하여 db에서 데이터를 검색하는 컨트롤러를 grails로 작성했습니다. 이제 grails default test를 사용하여 테스트하고 싶습니다. 당신이 당신에게 도메인 클래스 예를 모의 할 필요가 같은컨트롤러에서 도메인 클래스를 사용할 때 컨트롤러가 테스트 될 때 오류가 반환됩니다.

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.

답변

0

소리 :

그러나 그것은 오류를 반환

import spock.lang.Specification 
import grails.test.mixin.Mock 

@Mock([AppPreferences]) 
class YourControllerClassSpec extends Specification { 
... 
+0

감사합니다. 작동합니다. –

+0

하지만 grails 테스트에서 response.text를 출력 할 때 Null 값을 반환합니다. 그러나 grails에서 localhost 컨트롤러는 데이터베이스에있는 올바른 값을 렌더링합니다. –

+0

gsp로 무엇을 반환하고 있습니까? 그것은 렌더링 문 또는지도 또는 ...입니까? –

관련 문제