2 Comments
User's avatar
Dani Sandoval's avatar

This definitely takes the mystery out of doubles and spies, so thanks for the explanation! I'm nervous, though, that the way these tests are written makes them feel like they're testing "too much of the implementation". Is this a normal feeling? Or am I just too wrapped up in end-to-end testing to see the value in this level of testing?

Expand full comment
Ben Christel's avatar

Your observation is on point! This is one of the main reasons I rank the backdoor stubbing approach 3rd or 4th out of my 5 approaches. I do think backdoor stubbing has value when you need to get tests around legacy code. You only need to do minimal surgery to make the code testable, so the risk of breaking things is small compared to other approaches. That said, I would not recommend backdoor stubbing when TDDing new functionality from scratch.

Note that, in the code example we explored here, true end-to-end testing wasn't possible, because we would need access to Eliza's email account to assert that the email was delivered.

I'll write much, much more about these tradeoffs in future posts :)

Expand full comment