Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的控制器有这样的功能:
def go() { ... redirect(action: 'someOtherAction') }
在我的集成测试中,我如何断言控制器做了我认为它应该做的事情?
assertEquals 'someOtherAction', controller.????
这些都给出空值:
controller.response.redirectedUrl controller.modelAndView.viewName
编辑:
响应实例的捕获:
如果你的测试使用 grails 2.0 风格的@TestFor注解,你应该可以这样做:
@TestFor
controller.go() assert response.redirectedUrl == '/someUrl/someOtherAction'
响应不是控制器的属性;测试注释将其添加到测试类本身。