xctest

XCode 7: Unable to Convert OCUnit to XCTest

夙愿已清 提交于 2019-12-05 23:40:16
I upgraded the XCode to 7.0 and ran into compilation issues. XCode asked me to convert my test target to use XCTest and I followed the wizard screen. I'm unable to find any test targets and cannot finish converting. Does any one know how to fix this ? Thanks. Make sure you have selected the scheme of your test target (in the top-left scheme selector), then select Edit -> Convert -> To XCTest... This will make Xcode recognize the appropriate target. 来源: https://stackoverflow.com/questions/32707166/xcode-7-unable-to-convert-ocunit-to-xctest

Run XCTest bundle with simctl

蓝咒 提交于 2019-12-05 22:16:14
问题 I have a XCTest bundle which I can run through xcode on a simulator by using simctl . I am using the iPhone 6 iOS 9.1 simulator with the following environment variables: export SIMCTL_CHILD_TestBundleLocation="/Users/User/ios_app/DerivedData/primus/Build/Products/Debug-iphonesimulator/Tests.xctest" export SIMCTL_CHILD_XCInjectBundle="/Users/User/ios_app/DerivedData/primus/Build/Products/Debug-iphonesimulator/Tests.xctest" export SIMCTL_CHILD_XCInjectBundleInto="/Users/User/ios_app/DerivedData

Xcode 10 test failure when running on older iOS simulators - “Failed to load test bundle… no suitable image found”

你离开我真会死。 提交于 2019-12-05 19:58:25
问题 I've installed Xcode 10 and upgraded my iOS application to Swift 4.2. When I run my tests (both UI and Unit) via Xcode, on an iPhone simulator running iOS 12, the tests successfully start. When I attempt to run the tests on a simulator running a prior iOS version (e.g. iOS 10.3.1), I get a "failure to load the test bundle". These tests were running successfully on Xcode 9.4. I can run my app on this older simulator without an issue. The Xcode output is as follows ("Reading List" is the

iOS Swift: Separate AppDelegate for XCTest

Deadly 提交于 2019-12-05 12:07:22
问题 Due to a couple issues, I want the XCTest target in a project to run a separate app delegate. Using ObjC, this was a relatively straightforward process: manipulate main.m (see: https://stackoverflow.com/a/15725328/1299041). Since it seems that a Swift application is initialized with @UIApplicationMain in the AppDelegate, is it possible to initialize with a separate AppDelegate for the test target? 回答1: It's strongly unrecommended to add conditions to normal code checking if its being tested.

How can I verify existence of text inside a table view row given its index in an XCTest UI Test?

六月ゝ 毕业季﹏ 提交于 2019-12-05 08:23:35
I am using XCTest UI Test framework to check rows in a table view. In my test I need to verify the existence of text in a table view row given its index. I was thinking of using tableRows.elementBoundByIndex method, but it did not return anything. The number of rows returned by calling tableRows.count is zero. The table is present and filled because I can query the text inside the rows successfully: XCTAssertEqual(app.tables.staticTexts["Cute Alpaca"].exists) How can I verify existence of a text in a row given its index in an XCTest UI test? Kevin It turns out that tableRows doesn't actually

Access to project code from XCTestCase - UI Test

…衆ロ難τιáo~ 提交于 2019-12-05 05:30:43
I'm trying to setup UI Test in my project. I'm making a UI test that tries to login through my apps login prompt. In order to ensure that the login prompt is shown when the test launches, I'm trying to run ServerManager.logout() , which is in the project's codebase. This will cause the Login prompt to be shown on launch. import XCTest class SmokeTest: XCTestCase { override func setUp() { super.setUp() // Put setup code here. This method is called before the invocation of each test method in the class. // In UI tests it is usually best to stop immediately when a failure occurs.

XCTest: The bundle “target Tests” couldn’t be loaded because its executable couldn’t be located

允我心安 提交于 2019-12-05 04:14:09
I'm using XCode 6.2 and I have a project with several targets and with no tests. I'm trying to include now XCTest for one of the targets. To do so, I add a new "Cocoa Touch Testing Bundle" and select the target that I want as a host. When trying to launch the test with Cmd+U, the simulator launches, opens the app for some milliseconds and then it closes, launching this message: IDEBundleInjection.c: Error 4 loading bundle '/Users/pepito/Library/Developer/Xcode/DerivedData/Flight-gpauuftblwwxtvevnylzllkypkjy/Build/Products/Debug-iphonesimulator/target Tests.xctest': The bundle “target Tests”

Automatically Running a Test Case Many Times in Xcode

六眼飞鱼酱① 提交于 2019-12-05 03:39:27
In Xcode, is there a way for me run a single test case n times automatically? Reason for doing this is that some of my beta testers are encountering random crashes in my app. I see the crash logs in TestFlight, along with the stack trace, but I can't reproduce the crash. The crash happens infrequently but when it does, it always happens when users are trying to create a DB record, which then gets uploaded to a server. The problem with the crash logs is that my code does not make an appearance in their stack traces (all UIKit & CoreFoundation stuff - and different each time). My solution is to

Xcode 7 UI Testing with Cocoapods fails on device

会有一股神秘感。 提交于 2019-12-05 03:06:11
When trying to run my UI Tests on my device I get the error: XCTRunner[1476:104021] The bundle “AppUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle. 2015-11-23 20:58:53.903 XCTRunner[1476:104021] (dlopen_preflight(/var/mobile/Containers/Bundle/Application/FAC2EFB2-92C6-4668-96A7-C77CC5C4AE87/AppUITests-Runner.app/PlugIns/AppUITests.xctest/TrueMostUITests): Library not loaded: @rpath/UIColor_Hex_Swift.framework/UIColor_Hex_Swift Referenced from: /var/mobile/Containers/Bundle/Application/FAC2EFB2-92C6-4668-96A7-C77CC5C4AE87/AppUITests

API violation - multiple calls made to -[XCTestExpectation fulfill]

♀尐吖头ヾ 提交于 2019-12-05 02:32:21
I'm writing one of my first integration tests in Swift. I'm trying to check if an image exists at a particular url. I want to perform a head request and check the response's status code. I keep getting the error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'API violation - multiple calls made to -[XCTestExpectation fulfill]. I've tried making the expectation a weak variable. I have the following code/test: func testAndroidImagesExist() { weak var expectation: XCTestExpectation? expectation = expectationForNotification(kBaoNotification