XCTest is not testing a test methods defined in a generic subclass of XCTestCase

Our team just discovered that Darwin's XCTest is not testing a test methods that are part of a test case which is a generic subclass of XCTestCase.

Those methods are displayed in the Test Navigator and can be executed manually but are not executed by Product->Tests or command line tools on CI.

On the beginning I was thinking that the problem is part of discovery tool but those test methods are displayed in the Test Navigator so maybe it's something else.

class MockGenerator {}

class CustomTestCase<T>: XCTestCase {}

class CustomTests: CustomTestCase<MockGenerator> {
    func testA() throws {
        XCTAssertTrue(true)
    }
}

I believe this is a known issue that has been fixed in Xcode 12.5 beta 1. From the release notes:

XCTest now automatically includes specialized subclasses of Swift generic test classes when running tests on macOS 11.3, iOS 14.5, tvOS 14.5, watchOS 7.4, or later OS versions. This allows you to use generics to improve reusability of test classes. (23493200)

1 Like
Terms of Service

Privacy Policy

Cookie Policy