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.

Charlie S
  • 4,366
  • 6
  • 59
  • 97
  • Do you want the location to change during the test or on a per-test basis? – Oletha Jul 19 '16 at 10:50
  • Looking to do both ideally, but either would help. Do you know how Oletha? – Charlie S Jul 20 '16 at 12:54
  • 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... – Oletha Jul 20 '16 at 13:00
  • Yeah was under the impression using launch arguments to trigger dev code would be the only way. Thanks Oletha. – Charlie S Jul 21 '16 at 11:30

1 Answers1

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

Charlie S
  • 4,366
  • 6
  • 59
  • 97