I am working on Unit Tests for a groovy n grails application v-2.1.1
I have a createCriteria()
to mock, which looks like below controller code snippet:
def updateList = {
def Cr = Book.createCriteria()
def Find = Cr.list() {
and {
eq ("name", params.name)
eq ("age", params.age)
eq ("prop", params.prop)
}
}
}
My test method looks like:
void testUpdateList(){
try{
controller.request.method = 'POST'
controller.session.userName = "amy"
controller.params.name = "A1"
controller.params.age = "four"
controller.params.prop = "D1"
controller.updateList()
}catch(Exception ex){
ex.printStackTrace()
}
}
I am able to pass params
to the controller method through my test method.
Can you please help me in mocking createCriteria()
whith an example of Mocking the data so that I can validate it?
Thanks in advance amy