我在控制器中有这些东西:
def show{
render (contentType: "text/json"){
needid = stuff.id
owner = stuff.owner.username
title = stuff.title
}
当我使用浏览器时,“stuff/show/3”会显示 id 为 3 的内容
现在我的问题:
如何编写单元测试控制器,更准确地说,如何发送参数“3”?
我的建议:
void testShow(){
request.json = ???? //how to send id parameter?
controller.show()
println(response.text); // show me whats the response
assert '3' == response.text //assert something, not sure if correct
}
非常感谢 !