I'm working on a desktop email client right now, and I want to unit test my backend. However, I can't see a way to make that work. In order for my code to work, it has to connect to a working mail server. Unless I tie my unit tests to an email account, and make sure that account matches the state my tests expect, I don't see how I can manage this.
Does anyone have any ideas on how to test this sort of application, where it relies on external factors by design?
EDIT:
To add some details: I'm working on a C++ higher level mail client library for my application, which uses libEtPan, a C library, to actually handle the details of connecting to the mail server and interacting with it.
I would mock the email server, and configure that mocked object to accept/reject emails as appropriate (depending on your tests).
To do this effectively, you need an interface to talk to your email server through. For testing, the implementation is a mocked object. For deployment you substitute this with an implementation that talks directly to a mail server.
See this SO question for C++ mocking frameworks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With