AssertExpectations
的文档说“AssertExpectations 断言用 On 和 Return 指定的所有内容实际上都按预期调用。调用可能以任何顺序发生。”如果我想断言某些调用是按顺序发生的怎么办?
gomock 有 *Call.After(*Call)
为此,但我在作证中看不到任何类似的东西。有没有办法,或者我应该只使用 gomock?
最佳答案
Testify 目前不支持此功能,但在本期中对其进行了跟踪 https://github.com/stretchr/testify/issues/741 .
作证mock.Mock
对象通过 Calls
提供对有序调用的访问。属性 ( https://pkg.go.dev/github.com/stretchr/testify/mock#Mock ),您可以使用它来自己构建此功能。
关于unit-testing - 如何断言模拟方法调用与 testify 按顺序发生?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37940180/