Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Simulator Location using Xcode's UITesting

Just wondering if it is possible to use UITesting in xcode to somehow code in custom locations for the simulator. We have an app that involves a number of location changes and would be great if we could automate the changes in location as part of our UITesting suite.

like image 838
Charlie Seligman Avatar asked Jul 14 '16 09:07

Charlie Seligman


People also ask

How do I change the location of simulator in Xcode?

Allow location simulationSelect Run | Edit Configurations from the main menu or Edit Configurations from the run/debug configuration selector on the toolbar. Choose your configuration from the list and go to the Options tab. Select the Allow Location Simulation checkbox and click OK.

How do I change the default location in iOS simulator?

in iOS Simulator menu, go to Features -> Location -> Custom Location. There you can set the latitude and longitude and test the app accordingly. This works with mapkit and also with CLLocationManager.

How do I select simulator in Xcode?

Open Xcode and click Menu > Xcode > Preferences > Select Components, and then choose the simulator version you want to download.

How do I test UI in Xcode?

How to Run XCUI Tests on XCode. To run the XCUITests on XCode, you can click the highlighted icon below to see your newly created UI Test targets. You can hover on the “testExample()” test case and click the “Play” icon to run that specific test to see if everything was set up properly.


1 Answers

Found another question similar to this one so thought I would reuse the answer I just posted there:

"I think the best approach to this will be to use GPX files. These allow you to set the lat and long of a location. (For more details see here: https://blackpixel.com/writing/2013/05/simulating-locations-with-xcode.html)

However, I suspect you will need to call these from within the app itself and then use UI testing launch arguments (when you launch XCUIApplication) to stipulate which GPX files to use depending upon the test."

like image 163
Charlie Seligman Avatar answered Oct 31 '22 04:10

Charlie Seligman