For instance I have a class
@Immutable
class User {
String id
}
and I want to stub it in the way I used to stub java classes
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
}
But when the code executed I noticed student.id returned null. Is there a way to stub @Immutable groovy classes using Spock or I have to use metaClass?
我已经将grails版本升级到2.4.3,问题已解决。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.