【发布时间】:2013-07-15 21:41:56
【问题描述】:
我在控制器中有这些东西:
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
}
非常感谢!
【问题讨论】:
-
您认为该服务为何以及如何接受 JSON 请求?
-
我阅读了一些关于控制器单元测试的文档文件,这就是我能想到的。你能帮我吗?
-
从here开始。
标签: json testing grails parameters controller