简体   繁体   English

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

[英]How to unit test third-party email components in Delphi?

I'm writing some new code that involves POP3 manipulation. 我正在编写一些涉及POP3操作的新代码。 I'm trying to come up with a design that allows me to write tests, so it's fairly decoupled and exercises most of the new code I'm writing. 我试图想出一个允许我编写测试的设计,所以它相当分离并且练习了我正在编写的大部分新代码。

The problem I'm facing is that I still need to verify that the way I'm using some third party component for email is the right one. 我面临的问题是,我仍然需要验证我使用某些第三方组件的方式是正确的。 This involves testing, for example, strange responses from faulty POP3 servers. 这涉及测试,例如,来自有故障的POP3服务器的奇怪响应。

Right now, I'm using a mock POP3 client so I can test the logic around a possible scenario where the client gets either an error or a strange response. 现在,我正在使用模拟POP3客户端,因此我可以测试客户端获得错误或奇怪响应的可能情况的逻辑。 However, I still need to check that these assumptions are true and remain true after, for example, an upgrade of the third party components. 但是,我仍然需要检查这些假设是否正确,并在例如升级第三方组件之后保持为真。

Also, there's SMTP. 还有,有SMTP。 I know in the Java world you have Dumbster . 我知道在Java世界里你有Dumbster

What are my alternatives in Delphi? 德尔福有哪些替代方案? Write my own custom mini-servers using the usual suspects ? 使用通常的 嫌疑人写我自己的定制迷你服务器?

Well I hate to be the person to confirm what you suspect, but: 好吧,我不想成为确认你怀疑的人,但是:

(a) you're going to have to build your own (everybody's needs are different, and at least in Delphi there are no standard fixtures for this kind of integration testing equivalent to the Java Dumpster) and... (a)你将不得不自己构建(每个人的需求都不同,至少在Delphi中没有标准的固定装置用于这种类似于Java Dumpster的集成测试)和......

(b) I don't think you should assume Indy, because ICS and Synapse are great, and using their demos might get you want you want even faster... I would go with ICS, given a choice. (b)我认为你不应该假设Indy,因为ICS和Synapse很棒,并且使用他们的演示可能会让你想要你想要更快......我会选择ICS。 But if you know Indy better, then go with it. 但如果你更了解Indy,那就去吧。

(c) I tend to keep around a virtual machine running Linux, because I find it easy to test with the sort of POP3/SMTP servers that get actually used in the real world at ISPs around me, and if I cared about it, I'd probably create a VM for Windows + Exchange server, if I had MSDN licenses, and the ability to do so. (c)我倾向于使用运行Linux的虚拟机,因为我发现使用在我周围的ISP现实世界中实际使用的POP3 / SMTP服务器进行测试很容易,如果我关心它,我如果我有MSDN许可证,可能会为Windows + Exchange服务器创建一个VM,并且能够这样做。

Remember this ain't unit testing no more. 请记住,这不再是单元测试。 This is integration testing. 这是集成测试。 Even if you cram it all in with threads instead of processes, that's no unit test you've got there, it's an integration test. 即使你用线程而不是进程填充所有内容,也就是你没有进行单元测试,这是一个集成测试。

If you want all your developers to be able to test without setup, then create a QA-TEST-NETWORK BOX which is always available and which has various configurations on various standard ports, then your integration tests can run at any developer PC workstation with zero setup, inside your LAN. 如果您希望所有开发人员能够在没有设置的情况下进行测试,那么创建一个QA-TEST-NETWORK BOX,它始终可用并且在各种标准端口上具有各种配置,然后您的集成测试可以在任何开发人员PC工作站上运行在局域网内部进行设置。 Outside your LAN, in a WAN environment this gets a lot hairier. 在局域网之外,在WAN环境中,这会变得更加繁琐。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用版本控制中的第三方组件管理Delphi项目? - How do you manage your Delphi Projects with third-party components in Version Control? 您如何对与第三方 COM 对象交互并实例化的代码进行单元测试? - How do you unit-test code that interacts with and instantiates third-party COM objects? 如何停止从第三方组件重建.dcu? - How to stop rebuilding .dcu from third-party components? 如何在第三方Delphi应用程序中获取控件的属性列表和值? - How to get the property list and values of a control within a third-party Delphi application? 如何在不使用第三方组件的情况下在Delphi中创建Outlook加载项? - How to create an Outlook add-in in Delphi without using third party components? iOS上的Delphi XE2,带有Indy或第三方Internet组件 - Delphi XE2 on iOS with Indy or Third Party Internet Components Delphi XE3的第三方VCL组件在XE4中? - Delphi XE3 third party VCL components in the XE4? 如何从第三方覆盖Delphi对象 - How To Override a Delphi Object from a Third Party 有没有办法自动查找项目中使用的所有第三方组件? - Is there any way of automatically find all third-party components used on a project? delphi专家中的第三方依赖项 - Third party dependencies in a delphi expert
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM