Midas/DataSnap 项目中的 DUnit 测试

发布于 2024-07-08 06:35:43 字数 151 浏览 6 评论 0原文

的 Midas/DataSnap 项目中设置 DUnit 测试 如何

如何在 Delphi 2006

在 TRemoteDataModule 中设置 Dunit 测试 Delphi 2006 中的项目向导不适用于 TRemoteDataModule

How does one setup DUnit Testing in a Midas/DataSnap project in Delphi 2006

Edit

How does one set up a Dunit Test into a TRemoteDataModule
The project wizard in Delphi 2006 does not work with TRemoteDataModule

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

○闲身 2024-07-15 06:35:43

这个问题并不完全有意义。 单元测试在单独的项目中执行,而不是在 DataSnap 服务器内执行。 通常,连接到数据库的测试是集成测试而不是单元测试。 您到底想测试什么? 如果它是 TRemoteDataModule 中的实用方法,您应该将它们作为类方法提取到一个单独的类中,并在那里测试它们。 您不必实例化应用程序服务器来执行单元测试。

The question doesn't entirely make sense. Unit tests are performed in a separate project, not within your DataSnap server. Generally, tests which connect to a database are integration tests rather than unit tests. What is it, exactly that you want to test? If it's utility methods within, say, a TRemoteDataModule, you should extract those out into a separate class as class methods, and test them there. You should not have to instantiate an application server to perform unit tests.

请爱~陌生人 2024-07-15 06:35:43

对于上面的简洁回答感到抱歉,每当我在编辑帖子时按回车键时,iPad 都会发布帖子。

dUnit 旨在执行单元测试,而您要做的不是单元测试。

如果满足以下条件,则测试不是单元测试:

  • 它与数据库通信
  • 它通过网络进行通信
  • 它涉及文件系统
  • 它不能与任何其他单元测试同时运行
  • 您必须对您的环境执行特殊操作(例如编辑配置文件)来运行它。
  • 它不能孤立运行

如果您遵循 SOLID 原则(尤其是单一职责原则),那么使用 dUnit 测试您的类(无需测试 Midas/DataSnap 相关逻辑)应该相当简单。 实际上,您不需要测试 Midas/DataSnap 逻辑。

但是有一些方法可以对 Delphi 应用程序执行集成和行为测试。

就我个人而言,我不会使用 TestComplete,因为它不能与任何类型的 CI 服务器很好地集成,并且测试以专有的二进制格式存储(这使得合并差异或维护任何源代码控制系统中的更改都会出现问题)。

你可以尝试 dSpec,但我不确定 Jody Dawkins 是否会继续维护它。

我在一些项目上直接使用了 AutoIt BASIC 脚本语言,并且还使用了它的 .NET 程序集在另一个应用程序上使用 NUnit 和 C# 驱动 Delphi 应用程序。 虽然不完美,但 NUnit / C# 解决方案比我见过的用于执行 Delphi 应用程序功能/行为测试的任何解决方案都更加优雅。 不过,设置它确实需要一些努力。

Sorry for the terse answer above, the iPad posts whenever I hit return while editing a post.

dUnit is designed to perform unit testing, and what you are trying to do is NOT unit testing.

A test is not a unit test if:

  • It talks to the database
  • It communicates across the network
  • It touches the file system
  • It can't run at the same time as any of your other unit tests
  • You have to do special things to your environment (such as editing config files) to run it.
  • It can't run in isolation

If you follow the SOLID principles (especially the single responsibility principle), using dUnit to test your class (without testing the Midas/DataSnap related logic) should be reasonably simple. And really, you shouldn't need to test the Midas/DataSnap logic.

But there are ways to perform integration and behavioural tests on Delphi applications.

Personally, I wouldn't use TestComplete because it doesn't integrate well with any sort of CI server and the tests are stored in a proprietary binary format (which makes merging differences or maintaining changes in any source control system problematic).

You could try dSpec, but I'm not sure Jody Dawkins is maintaining it any more.

I have used the AutoIt BASIC scripting language directly on some projects, and also used its .NET assembly to drive a Delphi application using NUnit and C# on another. While not perfect, the NUnit / C# solution was more elegant than anything I'd seen for performing functional / behavioural testing Delphi applications. It did take some effort to get it setup though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文