在Delphi Mocks中mock.verify和mock.verifyAll有什么区别?它是否也验证了对其他模拟的期望? 我想验证我为当前单元测试创建的所有模拟的所有期望。
答案 0 :(得分: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;