Grails Unit Test Case -
my controller contains following action
def addnumber ={countrynumbercmd cmd -> def countryselected = params?.countryselected if(cmd.validate()) { println "success page" }else{ flash.cmd=cmd render(view:'hello') } }
my hello.gsp page contains following code
<html> <head> <title>hello</title> </head> <body> <div class="width460" id="formerrorjavascripttable"> <g:haserrors bean="${flash.cmd}"> <g:rendererrors bean="${flash.cmd}" as="list" /> </g:haserrors> </div> </body> </html>
and
message.properties
countrynumbercmd.countryselected.nullable = country value should not null.
command object validation class
class countrynumbercmd { string countryselected static constraints = { countryselected(nullable:false) } }
now can suggest me how assert country value should not null
in failed unit test case?
please find effort far !..
testaddnumber_countryselected_null(){ params.countryselected = null controller.addnumber() controller.response.reset() assertequals controller.modelandview.viewname,"/pcountry/hello" }
but want compare assertequlas validation message (as have passed "countryselected = null") with, message(code:"countrynumbercmd.countryselected.nullable")
can applied such assertion compare i18 validation message ? in advance far can assertequals flash.cmd.errors['countryselected'].getcode(),"nullable"
Comments
Post a Comment