用于货物内部集成测试的邮件服务器模拟
我有一个网络应用程序,目前正在不同级别上进行测试(junit 测试、运行 tomcat 的货物容器内的集成测试、htmlunit 等),我现在面临一个问题。
通过一些输入信息,我的网络应用程序正在生成一个 zip 文件,我可以在创建它的过程完成后下载该文件。至少使用 htmlunit 和一个货物容器测试不同的用例没有问题,启动单个 tomcat 内所需的所有应用程序和后端。
我的网络应用程序的新版本正在将生成的文件发送(javax.mail)到配置的电子邮件地址(我之前手动发送过该邮件),但我不知道如何集成测试它发送的内容以及是否成功了。
是否有任何模拟邮件服务器或类似的东西,我可以轻松地在我的货物测试容器中运行,在我的应用程序中配置它并断言它收到的所有邮件?
我不想使用在我的测试区域之外运行的静态邮件服务器,因为这些测试必须在不同的环境中运行(开发、Hudson、集成环境等),并且我将依赖于其状态和可用性。
如果没有,是否还有其他解决方案?非常感谢。
I've got a web application i'm currently testing on different levels (junit tests, integration tests within cargo container running a tomcat, htmlunit etc.) and i'm facing a problem now.
With some input information my web application is generating a zip-file i can download after the process creating it has been finished. At least there was no problem testing different use cases with htmlunit and a cargo container starting all applications and backends needed inside a single tomcat.
The new version of my web application is sending (javax.mail) the generated file to a configured email-address (i sent that mail manually before), but i can't figure out how to integration-test what it's sending and if it succeeded.
Is there any mock-mailserver or sth like that i can easily run inside my cargo testing container, configure it in my application and assert all the mails it has received?
i don't want to use a static mailserver running outside my testing area, because there are different environments these tests have to run inside (development, hudson, integration-environment etc.) and i would be dependent on its state and availability.
if not, are there maybe any other solutions? thank you a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会选择Dumbster。这是一个假 SMTP 服务器,带有一个 API,您可以通过查询来查明发送了哪些邮件。
您可以在测试开始时启动它,并在测试结束时检查发送的消息。 (无需部署在cargo中)
I'd go for Dumbster. It's a fake SMTP server with an API you can query to find out what messages were sent.
You can start it at the beginning of your test and check the sent messages at the end. (No need to deploy it in cargo)