【发布时间】:2021-12-22 13:37:14
【问题描述】:
我的测试只需要检查给定模拟方法的调用号,没有别的。
被测类和嵌入接口:
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 方法?
【问题讨论】:
标签: delphi mocking spring4d dunitx