Delphi 模拟向导

标签 delphi mocking delphi-2010

让我先说一下我对单元测试、模拟、 stub 等相当陌生......

我已经安装了 Delphi-Mock-Wizard。当我选择一个单元并“生成模拟”时,会创建一个新单元,但它非常基本,而不是我所理解的模拟。

 unit Unit1; 

(** WARNING - AUTO-GENERATED MOCK! Change this unit if you want to, but be aware that any changes you make will be lost if you regenerate the mock object (for instance, if the interface changes).

My advice is to create a descendent class of your auto-generated mock - in a different unit - and override things there. That way you get to keep them.

Also, the auto-generate code is not yet smart enough to generate stubs for inherited interfaces. In that case, change your mock declaration to inherit from a mock implementation that implements the missing interface. This,
unfortunately, is a violation of the directive above. I'm working on it.
You may also need to manually change the unit name, above. Another thing
I am working on. **)

 interface

 uses
   PascalMock,   
   TestInterfaces; 

 type   
   IThingy = interface; 

 implementation 

 end.

查看源代码,似乎有相当多的注释。我想知道,有人让这个工作吗?

我的IDE是D2010。

谢谢。

最佳答案

Delphi 模拟向导尚未完成。它几乎没有任何功能。您在问题中发布的输出看起来是该工具能够生成的唯一内容。如果你想使用它,你必须等到它成熟。由于上次更新是在 2008 年 10 月,因此您可能要等待很长很长的时间。

您必须为您的模拟需求选择不同的方向。请参阅之前的 Stack Overflow 问题以获取建议:

What is your favorite Delphi mocking library?

关于Delphi 模拟向导,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2694949/

相关文章:

Delphi 2010 及早期编译器

sql - 适用于 Delphi 2010 和 Unidac 的可视化 SQL 查询生成器

c++ - Delphi/C++ Builder - 在 TDBGrid 中设置事件/选定行颜色

c++ - Delphi:使用调试器调用 C dll 函数需要 15 秒,没有调试器需要 0.16 秒。为什么?

c# - 在 RhinoMocks 中使用回调触发器

android - 模拟位置在谷歌地图上不起作用

delphi - Process32Next不同的结果

excel - 无法让 Delphi ADOQuery 更新或插入到 Excel 工作表中

string - OleVariant 可用于 DLL 过程中的输出参数吗?

reactjs - 用于脚本加载的模拟实用程序函数