Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test email logic with Play Framework

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

like image 513
Touko Avatar asked May 08 '12 12:05

Touko


1 Answers

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("[email protected]");

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.

like image 50
Touko Avatar answered Oct 23 '22 15:10

Touko