我最近将项目从2.2升级到了2.4.4,并通过替换来升级了集成测试
IntegrationTest extends GroovyTestCase
和
@TestMixin(IntegrationTestMixin)
我的控制器具有保存方法,例如:
class IssueController {
def save() {
...
if (!issueService.save(issue)) {
render(view: "create", model: [issueInstance: issue])
return
}
}
和集成测试(在测试/集成中):
@Before
void setUp() {
ic = new IssueController()
}
@Test
void testValidSave() {
ic.params.issueNo = "test"
ic.save()
assert ic.flash.successAlert == "Saved issue test"
assert ic.response.redirectUrl == '/issue/list'
}
但是我的集成测试在调用ic.save()时不调用控制器的save方法(因此失败)。如果我将save()方法重命名为saveIt(),并调用ic.saveIt(),则一切正常
但我不想重命名所有控制器方法名称。
无需删除allowedMethods
或更改为GET,就像在测试用例中一样
ic.request.method = "POST"
如果允许的方法是发布。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句