XCTest &GPX 文件:可以自动启动位置更新吗? [英] XCTest & GPX Files: Can Location Updates Be Started Automatically?
问题描述
我在我的项目中添加了一个 gpx 文件;它的名字是 TrailOfHistory.gpx.我已经编辑了我的项目方案,以便 Xcode 9 使用此文件来执行位置更新.
以下是该方案的运行和测试配置的屏幕截图,其中我已指定应使用 gpx 文件:
当我运行我的应用程序时,用户位置更新(由 gpx 文件给出)自动开始.我可以在我的应用程序的 MKMapView 上看到这种情况.
相反,当我运行其中一项单元测试时,用户位置更新不会自动开始.我必须改为执行单击调试工具栏的模拟位置按钮并选择 gpx 文件的手动步骤;如以下屏幕截图所示:
我的最终目标是获得一组可以由持续集成系统执行的测试.所以,点击 Xcode 按钮不会飞.
谁能提供这方面的见解?特别是,任何人都可以说他/她有创建 XCTest 的经验,其中位置更新自动开始(如果是这样,那么我会带着希望继续前进;目前我不清楚我应该有什么期望)?
注意:我发现
- 在左侧为该方案选择测试",然后单击单元测试"目标的选项"按钮.
- 将位置"变量设置为您的 GPX 路径.
这些步骤使我能够按预期测试我的 CoreLocation 函数.
我觉得在写这个问题时这些选项可能不可用,但以防万一这有助于解决这个问题的人,我想我会在这里回答.
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:
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:
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.
I have managed to get this working using the following approach;
- Go to the relevant scheme and select 'Edit Scheme...'
- Select the 'Tests' for that scheme on the left hand side, and then click the 'Options' button for the UnitTest target.
- Set the 'Location' variable to your GPX trail.
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.
这篇关于XCTest &GPX 文件:可以自动启动位置更新吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!