1
成株@Immutable Groovy類比如我有一個類使用斯波克
@Immutable
class User {
String id
}
,我想它存根在我使用存根的Java類
def "should stub class"() {
given:
def validator = new BitSolutionValidator(eventBus)
def student = GroovyStub(User)
when:
validator.onStudentHandedOverBitSolution(new StudentHandedOverBitSolutionEvent(
student, GroovyStub(BitTask), GroovyStub(BitSolution)))
then:
student.id >> STUDENT_ID
}
的方式,但執行的代碼時我注意到student.id返回null。有沒有辦法使用Spock來存留@Immutable groovy類,或者我必須使用metaClass?
斯波克是在1.0版本的現在 – cfrick
有人猜測他指的Grails 2.4.3 – billjamesdev