我被困在如何编写测试上。我有以下公共功能。GetAccountNumber()有自己的逻辑。我想返回一个模拟值GetAccountNumber()。在 Java 中,我可以做到when(object.method()).thenReturn("returnValue"). 是否有类似的东西可用于 go 我如何才能做到这一点。我正在浏览一堆 go 文档,但还没有发现任何有用的东西。func GetConfigName() string { var configName string accountNumber := GetAccountNumber() switch *accountNumber { case "123": configName = "test1" case "456": configName = "test2" return configName}
添加回答
举报
0/150
提交
取消
