Grails 测试期间从控制器访问视图

Grails 测试期间从控制器访问视图,grails,cucumber,grails-controller,Grails,Cucumber,Grails Controller,我有一个控制器UserController,这个控制器有一个register方法,它使用一个服务注册一个用户,然后呈现输出 我正在使用Grails Cucumber插件,它创建一个UserController对象,设置参数,并调用userControllerObj.register 在cucumber测试的Then部分中,我可以调用userController.response.contentAsString,这将是我通过在此处呈现一些文本在userController中编写的任何文本 但是,

我有一个控制器UserController,这个控制器有一个register方法,它使用一个服务注册一个用户,然后呈现输出

我正在使用Grails Cucumber插件,它创建一个UserController对象,设置参数,并调用userControllerObj.register

在cucumber测试的Then部分中,我可以调用userController.response.contentAsString,这将是我通过在此处呈现一些文本在userController中编写的任何文本

但是,如果我在UserController register方法中将呈现从呈现字符串更改为呈现页面:renderview:registrationOK,我将无法获得任何输出:

userController.response是GrailsMockHttpServletResponse

userController.response.getText返回一个空字符串

userController.response.contentAsString返回一个空字符串

userController.response.contentType返回文本/html;字符集=utf-8

userController.response.contentLength返回0


userController.modelAndView.view返回null

userController.register;println response.text;