How to import my App module into MyAppUITests file?

前端 未结 5 1890
被撕碎了的回忆
被撕碎了的回忆 2021-01-08 00:00

This is my simple test case:

import XCTest
@testable import MyApp //it doesn\'t work

because of this:

class TabBar         


        
5条回答
  •  广开言路
    2021-01-08 00:35

    I solved the inaccessible symbol problem by pulling some stuff from my app target into two frameworks (model and view-model) that I can then import into my UI tests.

    As for accessing the actual memory of the executable, you can't, but you can test for things that should appear on screen somewhere in that mode. I use this assertion to e.g. check for the existence of a table view cell:

    XCTAssertTrue(tables.cells.staticTexts["Cell title I expect to exist"].waitForExistence(timeout: 1))
    

    Since you can use accessibility you can access a pretty decent amount of things this way. I suppose you could add an invisible label with a dump of your app's memory-in test mode only!

    I too make use of the launch arguments to configure my app for UI tests, as Michael suggested: https://stackoverflow.com/a/34469136/4789448.

提交回复
热议问题