Access to project code from XCTestCase - UI Test

…衆ロ難τιáo~ 提交于 2019-12-05 05:30:43
joern

Accessing your project's code via @testable import is only possible in UnitTests. When you are running UITests this is not working, because during a UITest your test class cannot access your app's code.

From Apple's Docs:

UI testing differs from unit testing in fundamental ways. Unit testing enables you to work within your app's scope and allows you to exercise functions and methods with full access to your app's variables and state. UI testing exercises your app's UI in the same way that users do without access to your app's internal methods, functions, and variables. This enables your tests to see the app the same way a user does, exposing UI problems that users encounter.

If you want to logout after a test you have to do it via your app's User Interface: If there is a logout button somewhere in your app, navigate there at the end of your test and let the test tap() it.

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