Running Junit Email Tests Without Emails Actually Going Out

前端 未结 7 817
执笔经年
执笔经年 2020-12-23 09:46

I want to run unit tests (Junit) on some model classes that typically will send emails confirming that things happened. Is there a mock email server that you can use with u

7条回答
  •  被撕碎了的回忆
    2020-12-23 10:37

    My solution was to wrap the mail server in a class which takes all the config options and has a send() method. In my tests, I'd mock this class and override send() with something that saves the current parameters for the assert.

    To test that the mail service itself works, send yourself a mail locally. Try hMail if you're on Windows.

提交回复
热议问题