Writing an Integration Test With a Mail Server
This is a simple example of code to demonstrate how to use the library fakesmtp-junit-runner to write integration tests.
The library has been released on GitHub and Maven Central.
Links : github.
The integration test comes from the github project : Source code
The example is quite straight forward.
First step: you have to declare the JUnit @Rule provided by the library.
Don’t forget to provide the appropriate server configuration to receive your mails :-) You can check Javadoc there
Second step: Injects with Spring or declares the component you have wrote to send mails
Third step: Write your testcases.
Don’t forget to declare in your test cases the relay domains that will be allowed to receive my your smtp servers. Mails that don’t match the relay domains are automatically rejected.