I am trying to write Spock Framework instead of Junit,
Test Class :
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
}
}
When I Run the above code using maven clean install command, I am getting the following error.
Error :
1*studentDao.getStudent(67) >>> new Student() (0 invocations)
If I Use 0*studentDao.getStudent(67) >>> new Student() I am Getting response.getEntity() is null
Aucun commentaire:
Enregistrer un commentaire