当我想验证在一种方法中模拟对象是否以特定顺序接收一些消息时,我会执行以下操作:
// sut is an instance of the class I am testing and myMock is a mock object injected in sut.
// I want to test that myMock sends messageA and then messageB, in that particular order.
[[[myMock expect] andDo:^(NSInvocation *invocation)
{
[[myMock expect] messageB];
}]
messageA];
[sut methodToTest];
[myMock verify];
有没有更清洁/更好的方法来做到这一点?提前致谢。