News for hackers. Stuff that matters.
Re:Mocks Aren't Stubs (2007) by backslash_16 on Monday November 14, 2016 @09:33PM (#12955166)
How do you test your code that interacts with external components, like sending emails to a mail server or making an external API call without using some sort of test fake or stub? (using the definition of them from the article)

I'm new to TDD and refactoring legacy code for testability. With the code architecture I have it looks and feels like I need either a mock, fake, or stub.

I'm using an IExternalComponent interface as a parameter and for the concrete implementation I can either pass the real thing (it's non deterministic, this works if the service is up) or I can pass a test double that allows me to throw exceptions at will and force failure conditions to be tested.

Is there another way of doing this that I am missing?

There are no comments on this comment yet.