Manuel Meyer
Feb 16, 2022

Wouldn't it be much easier and also better testing, if you just point your networking to another server, lets say 'localhost', and start an server or a server mock there for each test (-session)? Then the only difference between the tested app and the deployed app would be the server name string.

If you cant go that route for what ever reason, then instead of mocking URLSession and co, you should instead hide all networking in an object, like 'APIClient' and have that mocked instead. APIClient would only do the networking and conversion to standard types and would be passed as a dependency into 'NetworkManager' or any other object that than will transform the responses into domain model types.

Manuel Meyer
Manuel Meyer

Written by Manuel Meyer

Freelance Software Developer and Code Strategist.

No responses yet