如何断言模拟方法调用与 testify 按顺序发生?

bar*_*adu 7 unit-testing mocking go testify

文档AssertExpectations说“AssertExpectations 断言用 On 和 Return 指定的所有内容实际上都按预期调用。调用可能以任何顺序发生。” 如果我想断言某些调用是按顺序发生的怎么办?

gomock 有*Call.After(*Call)这个,但我在作证中看不到任何类似的东西。有没有办法,或者我应该只使用 gomock?

Cam*_*tle 1

Testify 目前不支持此功能,但在本期https://github.com/stretchr/testify/issues/741中对其进行了跟踪。

Testify 的对象通过属性 ( https://pkg.go.dev/github.com/stretchr/testify/mock#Mockmock.Mock )提供对有序调用的访问,您可以使用它自己构建此功能。Calls