我想写斯波克框架,而不是JUnit中,嘲讽没有出现在斯波克工作框架
测试类:
class StudentServiceSpec extends Specification{
@Shared def studentDao
@Shared def studentService
def setupSpec(){
studentDao = Mock(StudentDao)
studentService = new StudentService(studentDao)
}
def "Get Student Details Based on StudentId"(){
setup:
1*studentDao.getStudent(67) >> new Student()
when:
Response response = studentService.getStudent("67")
println "** Response "+response
println "** Response "+response.getEntity()
then:
response != null
}
}
当我使用maven干净的安装命令运行上面的代码,我得到以下错误。
错误:
1*studentDao.getStudent(67) >>> new Student() (0 invocations)
如果我使用0*studentDao.getStudent(67) >>> new Student()
我得到response.getEntity()
是null
你可以接受你的自己的回答 – kazanaki
哇,你救了我的夜晚:) thx – radio