Network mocking / stubbing framework

Which network mocking / stubbing framework are you using nowadays and can be recommended? It should be usable with SPM as well.

I've stumbled over OHHTTPStubs and Mockingjay, but they seem to have gotten quite little love in recent years.

I'm tending to not use a framework at all.

1 Like

I have used Mocker and am quite satisfied

1 Like

For regular old unit tests I tend to not rely on a framework. I have a single helper class in my tests, URLStubbing that basically fits all my limited needs.
I have used OHHTTPStubs in the past IIRC, but these days I find that I use so little functionality besides a rudimentary implementation of URLProtocol that I think adding another dependency for it is overkill.
URLStubbing is not even 160 lines long and includes a lot of documentation about how to use it I wrote for a junior dev I taught.

However, I want to point to Telegraph in this context. I use that for UI tests to mock responses for any requests my app sends out. It's basically a small webserver that runs inside the test runner. A couple of years ago I checked several similar libraries and this one fit that use-case best.
It's not directly a network mocking or stubbing framework, but I think it's close enough to the topic and perhaps useful for people relying on them for unit tests, too.

1 Like

Mocker is the tool I've been looking for! Thanks for your hint!