Delphi Mocks 中的 mock.verify 和 mock.verifyAll 有什么区别?它是否也验证了其他模拟的期望?我想验证为当前单元测试创建的所有模拟的所有期望。
1 回答
3
你可以告诉一个接口的模拟,它也可以模拟其他接口。如果您模拟的接口通过 Supports 询问另一个接口,这很有用。
Verify
检查直接模拟类型的期望是否同时VerifyAll
检查其他接口的期望。
例子
var
foo: TMock<IFoo>;
begin
foo := TMock<IFoo>.Create;
foo.Implements<IBar>;
foo.Setup.Expect.Once.When.DoThis;
foo.Setup<IBar>.Expect.Once.When.DoThat;
// pass mock to tested component which
// calls DoThis and Supports(IBar) and calls DoThat
foo.Verify; // checks if DoThis was called once
foo.VerifyAll; // also checks if DoThat on the mock as IBar was called.
end;
于 2017-03-17T21:55:03.000 回答