XCTest & GPX Files: Can Location Updates Be Started Automatically?
Asked Answered
V

1

5

I have added a gpx file to my project; its name is TrailOfHistory.gpx. I have edited my project's scheme so that this file will be used by Xcode 9 to perform locations updates.

Here are screen shots of the scheme's Run and Test configurations wherein I have designated that the gpx file should be used:

Scheme's Run Configuration

Scheme's Test Configuration

When I run my application, user location updates (as given by the gpx file) begin automatically. I can watch this happening on my application's MKMapView.

In contrast, when I run one of my unit tests, user location updates do not begin automatically. I must instead perform the manual step of clicking the debug toolbar's Simulate Location button and choosing the gpx file; as shown in the following screen shot:

Debug Toolbar's Simulate Location Menu

My ultimate goal is to arrive at a set of tests that can be executed by a continuous integration system. So, clicking on Xcode buttons is not going to fly.

Can anyone provide insight on this? In particular, can anyone say that he/she has had the experience of creating an XCTest wherein location updates began automatically (if so then I'll proceed with hope; currently I am unclear what expectations I should have)?

Note: I found this very similar question, over a year old. Hopefully I can generate some renewed interest.

Vancouver answered 22/3, 2018 at 19:43 Comment(1)
Did you finally find a solution @Vancouver ?Violaviolable
C
1

I have managed to get this working using the following approach;

  1. Go to the relevant scheme and select 'Edit Scheme...'

enter image description here

  1. Select the 'Tests' for that scheme on the left hand side, and then click the 'Options' button for the UnitTest target.

enter image description here

  1. Set the 'Location' variable to your GPX trail.

enter image description here

These steps are allowing me to test my CoreLocation functions as expected.

I feel like these options may have not been available when this question was written, but just incase this helps people with this issue going forwards I thought I would answer here.

Clarion answered 23/7, 2020 at 8:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.