xctest

“No such module” when using @testable in Xcode Unit tests

末鹿安然 提交于 2019-11-27 06:13:16
I recently updated to Xcode 7 beta 5. I tried adding a unit test to an earlier project, but I am getting the error message "No such module [myModuleName]" on the @testable import myModuleName line. I tried cleaning the project with Option Clean Build Folder checking that "Enable Testability" (debug) was set to Yes in the Build Options deleting the tests target and then re-adding the iOS Unit testing bundle None of this worked for this project (but I have gotten testing to work in another project). Has anyone else had this problem and solved it? Please check your Module Name that you try to

Xcode 5.0.2 dyld: Library not loaded: @rpath/XCTest.framework/Versions/A/XCTest

折月煮酒 提交于 2019-11-27 05:42:21
问题 I have problems running a project in Xcode 5.0.2 I get the following error: dyld: Library not loaded: @rpath/XCTest.framework/Versions/A/XCTest Referenced from: /Users/chris/Library/Developer/Xcode/DerivedData/relatio-cwlmozvklaldmictbbjthzuoxnxz/Build/Products/Debug/relatio.app/Contents/MacOS/relatio Reason: image not found (lldb) How do I solve this issue? 回答1: It looks like your main target is linking to XCTest.framework as well as your test target. It should only be linked to the main

XCTest and asynchronous testing in Xcode 6

末鹿安然 提交于 2019-11-27 03:55:40
So Apple said in the release note of Xcode 6 that we can now do asynchronous testing directly with XCTest. Anyone knows how to do it using Xcode 6 Beta 3 (Using objective-C or Swift)? I don't want the known semaphore method, but the new Apple way. I searched into the released note and more but I found nothing. The XCTest header is not very explicit either. Obj-C example: - (void)testAsyncMethod { //Expectation XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method Works!"]; [MyClass asyncMethodWithCompletionBlock:^(NSError *error, NSHTTPURLResponse

XCode 5 unit testing: starts my app

社会主义新天地 提交于 2019-11-27 03:27:29
When I run my tests in XCode 5, the main window of my OS X app appears on the screen for a couple of seconds while running the tests. Why? Even if I uncomment all my tests it still opens my main window. 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 to logic test (so it run faster and don't need to start your app first): go to build settings for

Running individual XCTest (UI, Unit) test cases for iOS apps from the command line

廉价感情. 提交于 2019-11-27 00:53:55
问题 Is it possible to run individual test cases, or individual test suites, from an iOS app test target, instead of all the test cases, from a command line interface? You can run tests from command line with xcodebuild, out of the box. When you do so, you run all of the test cases contained in the test target you've selected. You can also do so with scan from Fastlane, though I believe you're restricted to running all of the tests of the build scheme you select (as above), so it's not different

Xcode 7 UI Testing: how to dismiss a series of system alerts in code

旧城冷巷雨未停 提交于 2019-11-27 00:36:43
I am writing UI test cases using the new Xcode 7 UI Testing feature. At some point of my app, I ask the user for permission of camera access and push notification. So two iOS popups will show up: "MyApp Would Like to Access the Camera" popup and "MyApp Would Like to Send You Notifications" popup. I'd like my test to dismiss both popups. UI recording generated the following code for me: [app.alerts[@"cameraAccessTitle"].collectionViews.buttons[@"OK"] tap]; However, [app.alerts[@"cameraAccessTitle"] exists] resolves to false, and the code above generates an error: Assertion Failure: UI Testing

Adding Swift files to test target not fixing unit tests

本小妞迷上赌 提交于 2019-11-26 20:34:49
问题 I have looked at a lot of blogs and tried many things to get my Swift unit tests to work in Xcode 6.0.1 (or 6.1 for that matter). I'm trying to access classes in my app's target so I wrote this line: var vc: LoginViewController! Of course, I get the "Use of undeclared type 'LoginViewController'" error. I then try to add LoginViewController to my test target, but then I get "use of unresolved identifier" errors on other classes in my project. So I try to add those classes to my test target,

Xcode7 | Xcode UI Tests | How to handle location service alert?

落花浮王杯 提交于 2019-11-26 19:29:16
问题 I am writing UI Test Cases for one one of my app using the XCUIApplication, XCUIElement and XCUIElementQuery introduced in Xcode7/iOS 9. I have hit a road block. One of the screens in test case requires iOS's Location Services. As expected the user is prompted about allowing use of location service with alert titled: Allow “App name” to access your location while you use the app? with Allow & Don't Allow buttons. Problem is or so it seems that since the alert is presented by OS itself it is

“No such module” when using @testable in Xcode Unit tests

社会主义新天地 提交于 2019-11-26 15:09:36
问题 I recently updated to Xcode 7 beta 5. I tried adding a unit test to an earlier project, but I am getting the error message "No such module [myModuleName]" on the @testable import myModuleName line. I tried cleaning the project with Option Clean Build Folder checking that "Enable Testability" (debug) was set to Yes in the Build Options deleting the tests target and then re-adding the iOS Unit testing bundle None of this worked for this project (but I have gotten testing to work in another

XCode 5 unit testing: starts my app

半腔热情 提交于 2019-11-26 10:29:16
问题 When I run my tests in XCode 5, the main window of my OS X app appears on the screen for a couple of seconds while running the tests. Why? Even if I uncomment all my tests it still opens my main window. 回答1: 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