Xcode 7 Tests don't run but reports success

Emanuel picture Emanuel · Sep 28, 2015 · Viewed 7.7k times · Source

I'm trying to add a test target to my project, however When I run the tests it seems like the actual tests aren't being executed, instead Xcode reports success always, but the small square which indicates if the test passed or not remains clear.

I only have one test target and one class:

@implementation Tests

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testExample {
    // This is an example of a functional test case.
    // Use XCTAssert and related functions to verify your tests produce the correct results.
    XCTAssert(false, "");
}

- (void)testPerformanceExample {
    XCTAssert(false, "");
}

@end

The test should fail but it displays a popup saying success. Also, the test report says there are no tests.

If I try to run the tests individually the tests "succeed" but I get no information on the report and the square remains empty.

Any ideas on how to fix it?

Answer

faircloud picture faircloud · Jan 11, 2017

For anyone else facing this issue, check to make sure that your test class is inheriting from XCTestCase as opposed to XCTest. I was going crazy trying all of these solutions until I realized that I was inheriting from the wrong class. Xcode doesn't complain, it will simply say tests succeeded without running them. Hope this helps someone.