Grails 集成测试无法识别控制器保存方法

Grails integration test not recognising controller save method

我最近将一个项目从 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 
        } 
    }

和集成测试(在 test/integration 中):

@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() 方法重命名为 saveIt(),并调用 ic.saveIt(),一切正常

但我不想重命名我所有的控制器方法名称。

不需要删除allowedMethods或者不需要改成GET就在测试用例中做

ic.request.method = "POST" 如果允许的方法是 post.