grails - unit test on delete operation -
this delete operation want unit test and
def deleteroutinetable() { def deleteroutinetableid=params.id; def routinetable=routinetable.get(deleteroutinetableid); routinetable.delete() redirect(action: "routinetable") }
and test code...but shows error..as
def newroutintable=new routinetable(id:1,name: "routine",institution:1,endtime: new date(),starttime: new date()) newroutintable.save(flush:true) newroutintable.list().size()+1 when: controller.deleteroutinetable() then:newroutintable.list().size()-1 }
failure: |
testdelete(routine.routinetablecontrollerspec) | java.lang.nullpointerexception: cannot invoke method delete() on null object @ routine.routinetablecontroller.deleteroutinetable(routinetablecontroller.groovy:54) @ routine.routinetablecontrollerspec.testdelete(routinetablecontrollerspec.groovy:60)
Comments
Post a Comment