u/tpolecatTypelevelin r/scala • Recommends
On “Functional way of simulating external services/APIs without resorting to mocking?”
The general strategy is to talk about the *intent* to interact with an external service, which allows you to do much of your testing in these terms; i.e., you usually don't need to test that the email was actually sent, you need to test that the *request* to send an email contains the correct information, which shrinks the surface area of your integration testing. This talk by Ken Scambler explains this strategy very well I think.
A generalization of this idea is to abstract the meaning out of your program using `Free`, and providing multiple interpreters. This allows you to swap out production logic for test logic to simulate unusual failures and so on. It's kind of like mocking in spiri…