Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 7 Tests don't run but reports success

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?

like image 270
Emanuel Avatar asked Sep 28 '15 13:09

Emanuel


2 Answers

If you are building for iOS do you usually have Xcode set to run on a physical device? If so try setting it to run on the iOS simulator.

I found that if you have Xcode 7 set to on a physical device unit testing will behave exactly as you've described. Setting Xcode to run on the iOS simulator temporarily for unit testing fixed the problem right up, and now it works like a charm.

I hope this helps anyone running into the same problem. :D

like image 43
Martin Van Buren Avatar answered Sep 21 '22 23:09

Martin Van Buren


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.

like image 90
faircloud Avatar answered Sep 18 '22 23:09

faircloud