I have a project where we do http requests to public domains.
I am currently using Mox for testing and following their practices by having a callback for the http client and a implementation:
defmodule HttpClient do
@callback request(atom(), binary(), binary(), keyword(), keyword()) ::
{:ok, HttpClient.Response.t() | HttpClient.MaybeRedirect.t()}
| {:error, any()}
end
While it works great for tests with mocked data, I still find that these tests are double edged, as they are fully dependent on the correctness of data and format of it, we already had cases where the tests would pass and the application would fail at runtime.
I was wondering if maybe replacing this kind of mocked tests with a real local http server (similarly to how ecto uses sandbox) that exhibits real properties would be better and make for cleaner and easier to manage tests.
Any thoughts on this or tools you could recommend?






















