Would it be reasonable to expect that iOS unit tests will run on something that has network access?

Would it be reasonable to expect that iOS unit tests will run on something that has network access? I have a class that downloads files from a web endpoint. Trying to decide if I need to compose with a downloader to mock, however, that doesn’t really test the class. If we can rely on having a network, then I can just point to a file that will always be available.

Thanks

You have full internet access to download files during builds and on both Android Emulators and iOS Simulators.

I would recommend you consider mocking the download as relying on network access from the build machine may introduce a lot of instability in your unit tests. If you are trying to test that a class downloads a file, consider mocking the transport library and its function/functions or separate the actual download to a different class to minimize the custom code and use a dependency injection.

1 Like