开发者

Grails Integrationtest - Request Object

开发者 https://www.devze.com 2023-04-03 05:10 出处:网络
I\'m testing a controller and there I defined an action which uses a value from the requestobject. How can I mock the request object in an integration test?

I'm testing a controller and there I defined an action which uses a value from the requestobject.

How can I mock the request object in an integration test?

I know that integration tests don't run in an Servlet, so there is no Reques开发者_运维技巧tobject, but how do I obtain it?


Quickest thing is to mock needed methods using Map coercion:

myController.request = [ getHeader: { -> '0' } ]

(that link also includes Expando sample).

If you need extensive Request usage, try functional-test plugin.

0

精彩评论

暂无评论...
验证码 换一张
取 消