Search code examples
swiftxcodexcode-ui-testing

Is it possible to hide classes from ui tests


I have a few helper classes like UnlockedTestCase that configure my app for special scenario tests.

Theses classes show up in the test navigator without tests.

Is there a way to mark then as "not test classes" in order for them to be ignored by the test navigator?

UPDATE: Sample code:

class UnlockedTestCase: XCTestCase {
    var app = XCUIApplication()

    override func setUp() {
        super.setUp()

        continueAfterFailure = false

        app.launchArguments = ["uiTesting", "unlock"]
        app.launch()
    }
}

A test would then be written as:

class UnlockedUITests: UnlockedTestCase {
    func testButton() {
        XCTAssers(app.buttons["SomeButtonInTheUnlockedState"].exists)
    }
}

Solution

  • Assuming the following structure:

    MyTestHelperClassName: XCTestCase {
        //... your helper methods
    }
    

    Remove its subclass declaration of XCTestCase
    i.e the : XCTestCase part

    Then it will not appear in the "Test Navigator"