Reputation: 45692
I want to write unit tests for JavaMail. I'm already using prepared outlook server. So my question is what is the best way to write unit tests: I mean: what should I check?
Transport.send(msg)
)Upvotes: 2
Views: 4897
Reputation: 2135
For unittests (as MariuszS says) you should not connect to a real system. Have a look at JavaMail Mock2 https://github.com/salyh/javamail-mock2 ,this is designed for doing unittests with JavaMail and does not need a real system.
Its primarily focused on IMAP/POP3 but SMTP Mock is also available. Its available in maven central.
Features
Unsupported for the moment: IMAP extensions like IDLE, CONDSTORE, ... and casts to POP3Message/IMAPMessage, store listeners
Upvotes: 4
Reputation: 31587
Unit Tests are simple tests without relation to other systems. Integration Test can verify cooperation with other server like Outlook.
In Unit Test you should mock mail server and test only your own code. You are responsible for your code only. For simplicity mock mail server, emulate it behaviour (mock) and test corner cases.
Read this: What's the difference between unit tests and integration tests?
Upvotes: 5