Xcodebuild doesn't run tests that are subclasses of a XCTestCase subclass

Viewed 196

I am writing a RESTful API and since many entities in my database have similar behaviour, I managed to write a generic test case class that is meant to be subclassed by specifying a generic parameter type for each subclass:

class CrudEntityTests<Entity>: XCTestCase where Entity: Content, Entity: MySQLModel {
    ...
    createEntityTest() throws { ... }
    editEntityTest() throws { ... }
    noEntityTest() throws { ... }
    fetchEntitiesTest() throws { ... }
    deleteEntityTest() throws { ... }
    creationPerformanceTest() throws { ... }
}

Then any subclass of CrudEntityTest has to specify a concrete type. For example:

class PostTests: CrudEntityTests<Post> {
    ...
    testCreatePost() throws {
        try super.createEntityTest()
    }
    // Etcetera...
}

Now the problem is that if I do that, then xCode doesn't recognize a class like PostTests as part of the classes to test. If I run the tests manually by pressing the checkmark near the class name in xCode, they run. But if I try to make a test build with xCode by pressing ⌘ + U, all the tests that subclass CrudEntityTests are not run. Also, those tests are not run with the xcodebuild command. To be clear, if I modify PostTests in a way that it doesn't subclass CrudEntityTests, but it is a direct superclass of XCTestCase, then the tests are run with xcodebuild and by pressing ⌘ + U. Does anybody know how to fix this problem?

0 Answers
Related