Xcode Scheme Default Location is ignored in Tests

ぐ巨炮叔叔 提交于 2019-12-03 06:59:54

This one's a bit old, but since there were some relatively recent requests for the same thing, I've put together an example using Xcode 10. I have no idea if there were other issues back when this question was written, but here's how it works today.

For tests, you need to specify the GPX file to use in the scheme's Test settings. Here's an example from a test project I threw together:

Also, make sure that the scheme is marked "share" so that the settings get checked in to your source repo and get checked out by other users or your CI pipeline.

In the test project I put together, I included a GPX file for the Space Needle, and one for the Statue of Liberty. My run settings don't specify a GPX file or location, my unit tests use/expect the Space Needle and my UI tests use/expect the Statue of Liberty. All worked as expected. You could, of course, use one GPX file for all three targets.

One thing to keep in mind is that location data takes a bit of time to come in, so you need to use appropriate waitForExpectations checks in order to give the location manager time to settle.

I've posted the full project that demonstrates GPX files working with both XCTests and XCUITests on GitHub.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!