How to test email logic with Play Framework

五迷三道 提交于 2019-12-08 19:32:29

问题


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?

(Is there something like Mailer testing with Rails?)

br, Touko


回答1:


While writing this question, I found this link : Testing mail sending by using Mock Mailer.

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.



来源:https://stackoverflow.com/questions/10498878/how-to-test-email-logic-with-play-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!