I would like to test my iOS application with all the network conditions possible, including quality of the connection (offline, poor, good) and carrier (WiFi, 3G). For the former, others have already suggested using the Network Link Conditioner, e.g. here:
iPhone simulator - simulate 3G connection
which is just fine for the bandwidth and packet loss, but unfortunately it isn't able to change the carrier type that is reported to the simulator. So I'm looking for a not-so-hacky way of simulating changes in the carrier type. I said not-so-hacky because I have already come up with a hacky solution which, moreover, is incomplete as it can only deceive code which explicitly depends on Apple's famous Reachability
module. (Though if anyone is interested, I can post it here.)
Is there a way to hijack/tamper with what the SystemConfiguration
API reports?
Simulate Poor Network on iPhoneOpen the Settings app and navigate to the Developer option. Select the Network Link Conditioner under NETWORKING option. Now enable the Network Link Conditioner & choose the network profile you want, and start testing how your app works in different conditions.
iPhone Device. Go to your Settings and go to Developer menu. Like the Network Link Conditioner in macOS, you can choose a desired profile to simulate for example a poor connection (100% Loss), or a 3G connection and so on.
Download Hardware IO tools for Xcode. Download and install this tool, then open system preferences in you mac. You'll find the tool Network link conditioner installed there, for newer xcode versions you may find it in Xcode developer tools menu. Use it to control the network.
I use the excellent OHHTTPStubs
library to test these things.
You even specify the types of connections you want to mock and their speed. And it's easy to create mock network returns in the tests. Which means you're not testing across an actual network so your tests are more determinate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With