Search code examples
swiftxcodexcode8xcode-ui-testingui-testing

removing runtime discovered tests labeled with "rt"


We are facing the issue that Xcode detects runtime tests. Because of certain states of the tests these tests will always fail.

It's not possible to get rid of them, by cleaning the Project nor deleting the Derived Data.

Some Test classes are inherited by others.

Specs:

  • Xcode 8.3.3
  • Swift 3.1

Edit

Add more specific details

Subclass:

  • TestClassA: XCTestCase
    • func testA1()
    • func testA2()
  • TestClassB: TestClassA
    • func testB1()

Now the Problem is that when I run all tests for TestClassB Xcode will run testB1 and then testA1 and testA2. Both marked with rt and they will fail.

How can i achieve that this is not happening by not loosing the subclass structure.


Screenshot

Tests Screenshot


Solution

  • I assume you're overriding the setup and teardown do assure the app will be in the proper state for every test case, the problem here would be that the rT test will appear since the subclasses are inheriting the tests from their parent.

    To avoid this while maintaining the subclassing structure, keep the setup and teardown functions in the classes you have but move the tests to a subclass of the setup class.

    For example:

    Subclass:

    • TestClassA: XCTestCase // This one will have the setup and teardown for A
    • TestClassATests: TestClassA
      • func testA1()
      • func testA2()
    • TestClassB: TestClassA // This one will have the setup and teardown for B, and you may reuse A setup
    • TestClassBTests: TestClassB
      • func testB1()
      • func testB2()