问题标签 [dunit]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
727 浏览

delphi - 对 Firemonkey 应用程序进行单元测试

我正在尝试使用 RAD Studio XE2 附带的 DUnit 对 Firemonkey 应用程序 (C++) 进行单元测试。

问题是,DUnit 是一个 VCL 项目,这使我无法在测试项目中包含 Firemonkey 单元表单(例如:UfrmMain.h)。

即使我将 Visual 与 Logic(MultiTier/MVC)分开,我也不能将任何 Firemonkey 库包含到我的类中(有时这会很有用,当有一个类“CustomDatabase”具有 TConnection 类型的对象时,它只可用在 Firemonkey -当然只是一个例子)。

当我完全分离 firemonkey 代码并将其保留在表单上时,测试是可能的,并且逻辑/数据保留在纯 C++ 代码的类中。

那么,这个“障碍”其实是好事吗?强迫我使用 MultiTier/MVC?(C++ 中的这个东西对我来说是新的)或者我应该寻找单元测试的替代方案,让我也可以测试表单?

(你也可以推荐我在 github 上的一些 C++ 项目或以上述方式分离的代码示例,我可以在哪里依赖?)

0 投票
3 回答
1379 浏览

delphi - 如何一次从所有测试用例中查看 DUnit GUI 中的状态消息?

您可以TAbstractTest.Status在测试期间使用过程在 DUnit GUI 中显示一些调试消息。

但是当我运行这组测试时,我只能看到上次执行的测试的状态消息。我可以以某种方式查看完整的日志,而无需选择要运行的每个测试吗?

0 投票
1 回答
305 浏览

forms - 如何从 DUnit 测试中获取活动的 TGUITestRunner?

TGUITestRunner 表单代表 DUnit 测试结果,由 GUITestRunner.RunTest过程创建一次:

我想通过编写彩色状态消息在运行时扩展它。这是可能的,因为 GUI 底部的状态消息被放入 TRichEdit。所以我需要在我的 TTestCase 中的某个地方获得指向这个表单的指针。

我可以在不修复 DUnit 代码的情况下做到这一点吗?也许你可以推荐一些黑客?

0 投票
2 回答
1604 浏览

delphi - 在 Dunit 项目中,exe 版本信息被禁用,我该如何取回它?

为什么我不能在 Dunit Test 项目中设置版本信息?此项目禁用该复选框,但其他项目则禁用。看截图:

在此处输入图像描述

0 投票
1 回答
175 浏览

delphi - 什么会导致编译器不产生控制台输出

如果我添加一些单元,我有一个不会编译为控制台的 DUnit 项目。
项目 (dpr) 由向导创建并CONSOLE_TESTRUNNER定义。

使其失败的单元包括一些 VCL 组件,但没有对其运行任何测试。
我什至尝试设置链接器选项,但没有任何区别。
有人遇到过类似的问题吗?
只是为了澄清:这个项目是 Delphi 2010 中的 Win32。

0 投票
1 回答
207 浏览

python - 相当于 Delphi 中的 Python DocTest?

Delphi 是否有任何等效的 DocTest。我使用 DUnit,但我喜欢 Python DocTest 的想法。我在这里看到了一些答案,但我认为,对于简单的功能,像 DocTest 这样的可能没问题。我的目标是在编写函数时在注释标题中定义我的测试。像 :

0 投票
1 回答
295 浏览

delphi - 如何在 Delphi 中对第三方电子邮件组件进行单元测试?

我正在编写一些涉及 POP3 操作的新代码。我正在尝试提出一种允许我编写测试的设计,因此它是相当解耦的,并且可以练习我正在编写的大部分新代码。

我面临的问题是我仍然需要验证我为电子邮件使用某些第三方组件的方式是否正确。例如,这涉及测试来自故障 POP3 服务器的奇怪响应。

现在,我正在使用模拟 POP3 客户端,因此我可以围绕客户端收到错误或奇怪响应的可能场景测试逻辑。但是,我仍然需要检查这些假设是否正确,并且在例如升级第三方组件之后仍然正确。

此外,还有 SMTP。我知道在 Java 世界中你有Dumbster

我在德尔福有哪些选择?使用通常的 嫌疑人编写我自己的自定义迷你服务器?

0 投票
4 回答
1195 浏览

delphi - Delphi 7、DUnit 和 FastMM 错误地报告字符串

我正在使用 DUnit 和 FastMM 来捕获未完成的内存块,但似乎有一个错误。我不知道它是在 FastMM、DUnit 还是在 Delphi 本身中,但这里有:

  • 当我的测试用例有内部字符串时,测试会因内存泄漏而失败。如果我在不关闭 DUnit GUI 的情况下再次运行相同的测试,则测试通过。DUnit GUI 测试也会出现同样的情况,我相信出于同样的原因。我的应用程序中没有泄漏,证明 FastMM 在这些情况下不会生成泄漏报告。

  • 问题1:有没有办法在不设置 AllowedMemoryLeakSize 的情况下忽略它们

  • 问题2:我使用的是Delphi 7,如果这个修复在Delphi XE 中有什么消息吗?

  • 我的实际测试配置:

    • test.FailsOnNoChecksExecuted := True;
    • test.FailsOnMemoryLeak := True;
    • test.FailsOnMemoryRecovery := False;
    • test.IgnoreSetUpTearDownLeaks := True;

这是一个示例代码(仅实现)

谢谢!!!!

更新:我面临的问题记录在http://members.optusnet.com.au/mcnabp/Projects/HIDUnit/HIDUnit.html#memoryleakdetection 但是除了运行相同的测试之外,相同的链接没有提供解决方案再次。

0 投票
1 回答
296 浏览

delphi - How to use the XPObserver unit contained in dunit's DUnitWizard, to implement an observer pattern, or even a MVC pattern?

There are good examples of Observer pattern in Delphi, thanks to the wise questions & answers on Stackoverflow, such as Best way to implement observer pattern in Delphi and Are there any Videos/Screen casts or other resources on how to use Interfaces in Delphi?. From those stackoverflow questions, the following links of instructive materials are extracted:

  1. Joanna Carter's blog

  2. SourceMaking site

  3. TDelphiHobbyist's blog

  4. itte.no site

  5. dunit's DUnitWizard

In that second stackoverflow question, mghie described dunit's DUnitWizard's XPObserver.pas as very interesting and other XP*.pas as worthing a closer look. However, the XPObserver unit is referenced only in two places, in dunit\Contrib\DUnitWizard\Source\Common\dunit\XPObserverTests.pas where the only interest of the test seems to be checking of reference counting, and dunit\Contrib\DUnitWizard\Source\DelphiExperts\DUnitProject\XPTestedUnitUtils.pas where only the IXPFamily type declared in the XPObserver unit is used.

I therefore wonders what is the best practice of using this XPObserver unit.

For example: Design questions, such as:

(1) How to use the XPObserver unit to implement an observer pattern that do something?

(2) How to use XPObserver to implement a MVC pattern?

Or coding questions like:

(3) XPObserver's TXPSubjects is claimed to provide the capability of enabling single observer<->multiple subject relation. However, FSubjects is declared private. There is also no getters. I wonder is this by design? (For example, the author has written // ...***DON'T*** refactor this method!! in TXPSubject.DeleteObserver. I am thus not confident to modify the code because I cannot understand this and maybe other parts completely.) If so, what is the supposed way to use TXPSubjects to enable single observer<->multiple subject relation?

Thank you very much for your time and comments!

0 投票
3 回答
601 浏览

delphi - 如何编译 DUnit2

我刚刚从 SVN 下载了 DUnit2 代码库。有人编译成功了吗?为了编译它,我必须遵循哪些步骤/先决条件?有人知道是否存在已经编译的版本吗?

谢谢你

法比奥维莱