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.
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.
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.
Open Xcode and click Menu > Xcode > Preferences > Select Components, and then choose the simulator version you want to download.
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.
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."
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