4 ms·
How do you test the code that needs to send an email, if your "SendEmail" function is not in a separate class that can be mocked? (ok, you can use a fake smtp
by koevet 11y ago
How do you test the code that needs to send an email, if your "SendEmail" function is not in a separate class that can be mocked?
(ok, you can use a fake smtp server, but it makes tests more complex, imo)
- spinningarrow 11y agoWhy can't you mock the function? Mocks aren't specific to classes.
- MichaelGG 11y agoIf you're passing an object in, you can just as easily pass in a function. Though I was explicitly referring to the case where the code is literally rewriting static functions into objects without using any actual OO features - just adding extra noise.