我的测试只需要检查给定模拟方法的调用号,仅此而已。
测试类和嵌入式接口:
type
IMyInterface = interface ( IInvokable )
['{815BD1B0-77CB-435F-B4F3-9936001BA166}']
procedure bar;
end;
TMyClass = class
private
fMyInterface : IMyInterface;
public
procedure foo;
end;
procedure TMyClass.foo;
begin
if ( someCondition ) then
fMyInterface.bar;
end;
测试用例:
procedure TMyClassUnitTest.foo_bar_NotCalled;
begin
fMyTestedObject.foo;
fMyInterfaceMock.Received( 0 ).bar;
end;
跑步者说foo_bar_NotCalled
:
No assertions were made during the test!
我还应该做什么?我应该调用什么 Assert 方法?