Change Simulator Location using Xcode's UITesting
Asked Answered
G

1

10

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.

Ghetto answered 14/7, 2016 at 9:19 Comment(4)
Do you want the location to change during the test or on a per-test basis?Jaxartes
Looking to do both ideally, but either would help. Do you know how Oletha?Ghetto
I've investigated before and now but still can't get the basic GPX configuration to work... From the sounds of it, there's no mechanism for simulating a location change mid-test. My recommendation would be to mock Core Location objects in the app when it's under test, triggered by a launch argument. Unsure as to how well that would work for changing location mid-test though...Jaxartes
Yeah was under the impression using launch arguments to trigger dev code would be the only way. Thanks Oletha.Ghetto
G
1

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."

Ghetto answered 26/7, 2016 at 9:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.