How to test email logic in the Play Framework

I have a class that extends Mailer and would like to have automated tests for this.

Using mock mailer I can get mail to the console, but how to check mail logic from an automatic test?

(Is there something like Validating Mailer with Rails ?)

br, Touko

+6
source share
1 answer

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

Thus, you can access the mail sent by the Mock mailer using the play.libs.Mail.Mock file as follows:

String email = Mail.Mock.getLastMessageReceivedBy(" joe@example.com "); 

Mail is returned as a single line, but better than nothing.

At least share it, because it took me a while to find it.

+13
source

Source: https://habr.com/ru/post/915196/


All Articles