如何使用Play Framework测试电子邮件逻辑 [英] How to test email logic with Play Framework
问题描述
我有一个扩展Mailer的类,并希望自动测试。
I got an class that extends Mailer and would like to have automatic tests for that.
使用模拟邮件程序,我可以将邮件发送到控制台,但如何测试邮件自动测试的逻辑?
With mock mailer I can get the mail to console but how to test mail logic from the automated test?
(有什么像邮件测试与Rails ?)
br,Touko
推荐答案
在撰写此问题时,我发现此链接:使用Mock Mailer测试邮件发送。
While writing this question, I found this link : Testing mail sending by using Mock Mailer.
所以,可以通过play.libs.Mail.Mock邮件发送Mock邮件的邮件,如下所示:
So, one can access mails mailed with Mock mailer with play.libs.Mail.Mock as follows:
String email = Mail.Mock.getLastMessageReceivedBy("joe@example.com");
邮件作为一个字符串返回,但比没有更好。
The mail is returned as one string but that's better than nothing.
虽然分享了这一点,因为花了我一段时间才找到这个。
Though to share this since it took me a while to find this.
这篇关于如何使用Play Framework测试电子邮件逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!