Unit testing Abstract classes in GroovymockForConstraintsTests 추상적 인 그루비 클래스
내가 단위 테스트 및 도메인 클래스를 조롱에 대한 이전 질문을,하지만 난 충분히 특이 생각하지 않습니다. 가 [toplevel.domain.Party] 클래스의 새 인스턴스를 만들 수 없습니다 : 여기
import grails.test.*
import toplevel.domain.*
class PartyTests extends GrailsUnitTestCase {
Party party
protected void setUp() {
super.setUp()
party = [:] as Party
mockForConstraintsTests(Party, [party])
}
protected void tearDown() {
super.tearDown()
}
void testNullRolesIsValid() {
party.roles = null
assertTrue "The roles should be nullable", party.validate()
}
}
테스트 결과입니다 :
package toplevel.domain
abstract class Party {
static hasMany = [roles:PartyRole]
static constraints = {
roles(nullable:true)
dateCreated(display:false)
lastUpdated(display:false)
}
List roles
Date dateCreated
Date lastUpdated
}
가 여기 내 단위 테스트입니다 : 나는 도메인 클래스가 있습니다!
org.codehaus.groovy.grails.exceptions.NewInstanceCreationException
: 는 [toplevel.domain.Party] 클래스의 새 인스턴스를 만들 수 없습니다! 에서 : grails.test.GrailsUnitTestCase.mockForConstraintsTests (111 GrailsUnitTestCase.groovy)에서 grails.test.MockUtils $ prepareForConstraintsTests.call (알 소스)에서 : grails.test.MockUtils.prepareForConstraintsTests (540 MockUtils.groovy)에서 PartyTests.setUp (PartyTests.groovy : 9) : $ _GrailsTest_groovy _run_closure2.doCall (_GrailsTest_groovy 147)에서 _GrailsTest_groovy $ _run_closure4.call에서 (_GrailsTest_groovy) _GrailsTest_groovy $ _run_closure1_closure19.doCall에서 (_GrailsTest_groovy _GrailsTest_groovy $ _run_closure4.doCall (203 _GrailsTest_groovy)에서 : 113) 에서 _GrailsTest_groovy $ _run_closure1.doCall (_GrailsTest_groovy : 96)에서 TestApp $ _run_closure1.doCall (TestApp.groovy : 66) 에서 gant.Gant $ _dispatch_closure4.doCall (Gant.gr oovy : 에서 344) : gant.Gant.withBuildListeners (Gant.groovy에서 gant.Gant $ _dispatch_closure6.doCall (Gant.groovy)에서 334) : gant.Gant $ _dispatch_closure6.doCall (Gant.groovy에서 324) gant.Gant.this $ 2 $ withBuildListeners (Gant.groovy) gant.Gant $ this $ 2 $ withBuildListeners.callCurrent (알 수없는 소스) gant.Gant.dispatch (Gant.groovy : 334) at gant.Gant.this $ 2 $ dispatch (Gant.groovy) at gant.invokeMethod (Gant.groovy) at gant.Gant.processTargets (Gant.groovy : 495) at gant.Gant.processTargets (Gant.groovy : 480)에 의해 발생했습니다. : java.lang.InstantiationException
이해가 안됩니다. 클래스의 인스턴스를 만들어 mockForConstraintsTests 메서드에 제공했습니다. 내가 도대체 뭘 잘못하고있는 겁니까?