gpt4 book ai didi

Delphi 模拟向导

转载 作者:行者123 更新时间:2023-12-03 18:19:59 26 4
gpt4 key购买 nike

让我先说一下我对单元测试、模拟、 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com