Lvsti
Lvsti

Reputation: 1525

How to fake network connection type changes in iOS simulator?

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?

Upvotes: 10

Views: 8738

Answers (2)

Daij-Djan
Daij-Djan

Reputation: 50089

Use the Network Link Conditioner that the Xcode tools provides

install it using this: Installing Apple's Network Link Conditioner Tool

Upvotes: -1

Abizern
Abizern

Reputation: 150605

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.

Upvotes: 2

Related Questions