Mocking is Not working in Spock Framework
<p>I am trying to write Spock Framework instead of Junit, </p>

<p>Test Class :</p>

<pre><code>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) &gt;&gt; new Student()

    when:
    Response response = studentService.getStudent("67")
    println "** Response "+response
    println "** Response "+response.getEntity()

    then:
    response != null
    }
}
</code></pre>

<p>When I Run the above code using maven clean install command, I am getting the following error.</p>

<p>Error :</p>

<pre><code>    1*studentDao.getStudent(67) &gt;&gt;&gt; new Student()   (0 invocations)
</code></pre>

<p>If I Use <code>0*studentDao.getStudent(67) &gt;&gt;&gt; new Student()</code>
I am Getting <code>response.getEntity()</code> is <code>null</code></p>