xctest

Why using implicit unwrap or force unwrap letting the app crash at some stage not beneficial?

青春壹個敷衍的年華 提交于 2020-01-05 04:22:06
问题 My point is at some places we know that the variable won't have nil at all but due to some reason we can't instantiate it in the class's init function so we have to make it optional. I also know that we can use optional binding or guard techniques to get rid of it easily. But letting the app crash at some really stupid mistakes because of the implicit unwrap/force unwrap is beneficial for the developers at the developing phase in my opinion . My example would be: class

Mock NSHTTPURLRequest and NSHTTPURLResponse in iOS unit test

六月ゝ 毕业季﹏ 提交于 2020-01-03 17:07:14
问题 I'm developing a framework in iOS which makes HTTP calls to server.I wanted to write unit test to test the API's.I wanted to mock the server calls,without actually making real server call.Can anyone help me with sample unit test which makes mocked server calls.How to do we set expectations and return the hand constructed url response.?I'm using XCTest framework for unit test and OCMock for mocking objects. 回答1: Here is how you might mock sendAsynchronousRequest: NSDictionary *serverResponse =

How to test if a UIImageView contains an image with a specific name using XCUITest?

允我心安 提交于 2020-01-02 21:55:18
问题 I have a collectionView that has a bunch of cells that contain a single UIImageView in each cell. I want to test wether or not in each cell, the imageView's image matches the correct image name. In the production code, I've added an accessibility identifier to the UIImageView example: "My Image View". I loop through an array of strings containing image names and set the cell's image in accordance to the index, example: ["image0.png", "image1.png", "image2.png"] so cells at index 0-2 would

Check the position of the XCUIElement on screen while testing iOS Application using XCTest

一世执手 提交于 2020-01-02 05:32:07
问题 I am testing an iOS Application and currently I am checking the existence of a particular XCUIElement using isHittable . I wanted to know if we can also check the position of the XCUIElement on the view. For instance, if we have a button in the bottom right corner of the view, can we check if it is actually in the bottom right corner using XCTest framework? I had a look at the Apple Documentation for XCTest framework but did not get any clue. Any help will be greatly appreciated. 回答1:

Access to project code from XCTestCase - UI Test

拥有回忆 提交于 2020-01-02 03:25:21
问题 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

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

夙愿已清 提交于 2020-01-02 01:59:08
问题 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

iOS Testing: Is there a way to skip tests?

心不动则不痛 提交于 2020-01-02 00:39:12
问题 I don't want to execute certain tests if the feature is currently disabled. Is there a way to "skip" a test (and to get appropriate feedback on console)? Something like this: func testSomething() { if !isEnabled(feature: Feature) { skip("Test skipped, feature \(feature.name) is currently disabled.") } // actual test code with assertions here, but not run if skip above called. } 回答1: You can disable XCTests run by Xcode by right clicking on the test symbol in the editor tray on the left. You

Finding elements by xpath in Appium using XCUITEST driver

假如想象 提交于 2020-01-01 18:40:10
问题 The task of updating an automation framework has fallen upon me. I'm new to iOS testing so I'm having trouble with the new XCUITEST driver in Appium-1.6.0-beta1. I have the driver up and running, but the majority of elements are located using xpaths in the framework (not at all ideal I know) the majority of elements do not have labels, names, or accessibility tags. Thus :name locators are ruled out for 90% of elements at the moment. The xpaths seem to be catering to the old apple framework

Finding elements by xpath in Appium using XCUITEST driver

浪子不回头ぞ 提交于 2020-01-01 18:38:16
问题 The task of updating an automation framework has fallen upon me. I'm new to iOS testing so I'm having trouble with the new XCUITEST driver in Appium-1.6.0-beta1. I have the driver up and running, but the majority of elements are located using xpaths in the framework (not at all ideal I know) the majority of elements do not have labels, names, or accessibility tags. Thus :name locators are ruled out for 90% of elements at the moment. The xpaths seem to be catering to the old apple framework

Could not determine bundle identifier for xxxTest TEST_HOST

笑着哭i 提交于 2020-01-01 02:47:18
问题 We do have troubles getting our CI to work with Xcode. We encounter the issue Could not determine bundle identifier for xxxTest TEST_HOST: some path that does not exist . What we have done so far: On the CI Machine we are able to run all tests on the device, but if we trigger it with a commit the CI does end in that error. We had that issue on other machines too, when we tried to run the tests of the application. We fixed that by cleaning the machine and reboot the devices.(Had do fix some