我有以下代码:
void testConfirmBookNotFound() {
def book = new Book(id: 1, title: 'test book')
mockDomain(Book, [book])
mockDomain(BookProject, [new BookProject(id: 1, book: book)])
def controller = new CancelController()
controller.params.id = 5140
controller.confirm()
assertEquals "/admin/cancel/index", controller.response.redirectedUrl
}
如果我的测试类扩展ControllerUnitTestCase
,那么controller.response.redirectedUrl
总是null
. 但是,如果我的测试类扩展GrailsUnitTestCase
(我已经读过它是针对空 url 问题的修复),那么我会得到No such property: params
. 我需要做什么才能让这个测试生效?