“No such module” when using @testable in Xcode Unit tests
Please check your Module Name that you try to import with @testable import “ModuleName”. The module name should be the same on Target->Build Settings-> Product Module Name
Please check your Module Name that you try to import with @testable import “ModuleName”. The module name should be the same on Target->Build Settings-> Product Module Name
It is now possible with Xcode 8 using the -only-testing parameter with xcodebuild: xcodebuild test -workspace <path> -scheme <name> -destination <specifier> -only-testing:TestBundle/TestSuite/TestCase
I spent some time figuring this out. If you read this documentation you find that Xcode has two modes for running tests. Logic Tests and Application Tests. The difference is Logic tests build their own target with your Classes and symbols built right in. The resulting executable can be run in the simulator and reports … Read more
Xcode 7.1 Xcode 7.1 has finally fixed the issue with system alerts. There are, however, two small gotchas. First, you need to set up a “UI Interuption Handler” before presenting the alert. This is our way of telling the framework how to handle an alert when it appears. Second, after presenting the alert you must … Read more
Obj-C example: – (void)testAsyncMethod { //Expectation XCTestExpectation *expectation = [self expectationWithDescription:@”Testing Async Method Works!”]; [MyClass asyncMethodWithCompletionBlock:^(NSError *error, NSHTTPURLResponse *httpResponse, NSData *data) { if(error) { NSLog(@”error is: %@”, error); }else{ NSInteger statusCode = [httpResponse statusCode]; XCTAssertEqual(statusCode, 200); [expectation fulfill]; } }]; [self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error) { if(error) { XCTFail(@”Expectation Failed with error: %@”, error); } }]; … Read more
You are running application test, not logic test. This means an instance of your app will be started and then run the unit tests. This allow you to perform some integration test that require your app is running. Here is the guide to setup application test and logic test. If you want to change it … Read more
You can add a “Run Script” phase to build phases in your test target to uninstall the app before running unit tests against it, unfortunately this is not between test cases, though. /usr/bin/xcrun simctl uninstall booted com.mycompany.bundleId Update Between tests, you can delete the app via the Springboard in the tearDown phase. Although, this does … Read more