xctest

Any way to automate SFSafariViewController in UI tests?

血红的双手。 提交于 2019-12-05 01:55:09
Is there any way to automate SFSafariViewController? I like the Xcode 7 UI test feature, but it seems it does not support SFSafariViewController automation. Some of the UI flows I am testing require a web browser so the app uses SFSafariViewController to make it safer vs a web view. If it's similar to launching extensions (currently broken with direct interactions), try tapping the screen at the point where the element you're looking for is: Example of tapping an action sheet which launches an extension: func tapElementInActionSheetByPosition(element: XCUIElement!) { let tableSize = app.tables

Asynchronous Performance Tests with XCTest

余生长醉 提交于 2019-12-05 01:14:08
I have started to explore the new XCTest APIs for asynchronous and performance testing. In isolation, the Apple examples from WWMC work well, but I have been unable to figure out how to combine them. The best I have been able to come up with is the following, but I receive the following error when it runs: API violation - call made to wait without any expectations having been set. XCTestExpectation *clsQueryReturnedExpectation = [self expectationWithDescription:@"clsQuery returned"]; PFCLSClient *theClient = [[PFCLSClient alloc] init]; [self measureMetrics:@[XCTPerformanceMetric_WallClockTime]

Can't use Swift classes inside Objective-C unit test

假如想象 提交于 2019-12-05 00:48:45
I have followed this recipe in order to use a Swift class in an existing Objective-C project MyProject . That works fine. However, I'm still not able to use the same Swift class in the same project's unit tests. The compiler marks the line where my Objective-C unit test says #import "MyProjectTests-Swift.h" with file not found . If tried changing the test target's Product Module Name from its default MyProjectTests to MyProject as suggested in a comment to this (unanswered) question. However the compiler now marks the line where my Objective-C unit test says #import "MyProject-Swift.h" with

iOS Testing: Is there a way to skip tests?

走远了吗. 提交于 2019-12-04 23:27:43
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. } You can disable XCTests run by Xcode by right clicking on the test symbol in the editor tray on the left. You'll get this menu, and you can select the "Disable " option. Right clicking again will allow you to re-enable.

XCUITest interact with a Notification Banner.

馋奶兔 提交于 2019-12-04 16:43:24
Is it possible in XCUITest to validate that a notification banner is sent to the screen? I can add an accessibility identifier to the notification, but I am having a problem getting XCUITest to interact with it when the banner is ent to the screen. I know that XCUITest runs in a separate process from the app, but was wondeering if it was still possible to interact with the notification or is it beyond the scope of XCUITest? Thanks, With Xcode 9 this is now possible. You can get access to other apps. That includes the springboard which contains the Notification banner. XCUIApplication now has a

UITesting, XCTest current ViewController Class

最后都变了- 提交于 2019-12-04 16:11:01
问题 Simple problem. I got button which perform segue to next view controller. I want to write UI XCTest to tell me did it open view controller i wanted. 回答1: The UI Testing framework doesn't have access to your applications code which makes class assertions on instances impossible. You are not able to directly tell the class of the controller which is on screen. However, if you think about your test a little differently you can make a very similar assertion. Write your tests as if you are the

How do I install the XCUITest runner app and ipa on a real device and get the results?

帅比萌擦擦* 提交于 2019-12-04 16:06:06
How do I install the XCUITest runner app and ipa on a real device and get the results? I have a runner.app that was generated by building it for testing, and a deployed/signed .ipa. Now what I would like to happen is to have it installed on a real device, execute it, and get the device log. Edited with answer... It is possible to achieve this. In order to build an ipa of the UI Testing app bundle you can follow these steps: Open your project containing in Xcode. Select the device you'd like to build the ipa for next to the scheme. This can be an actual device or a simulator. Product > Build

Xcode UI test manual snapshot

本小妞迷上赌 提交于 2019-12-04 10:02:45
I want to manually take some snapshots from my applications using UI Tests intoduced in Xcode 7. By default, Xcode takes screenshots of every step and in result I got screenshots that was taken in the middle of transitions between view controllers. I want to manually take snapshot in the specific moments. Any ideas how to do this? I know how to take screenshot of UIView, but XCUIApplication doesn't provide any API to get UIView objects. I've created a library for this: https://github.com/zmeyc/UITestUtils The idea is to take the screenshot in the app itself and send it to the test app via

XCTest Swift - How do I swipe faster or more precisely?

夙愿已清 提交于 2019-12-04 08:36:49
问题 I have tests in XCTest using Swift and I am trying to swipe through a feed until a condition is met. I am using the swipeUp() , but the problem with this is it acts like a human swipe and has this painful animation of slowing down when it lets go. It doesn't try the swipe again until the slowing-down-animation is complete. Additionally, that method takes no arguments. I would like to see if there is something like Calabash or shoot even Androids Espresso where there are properties to a swipe

Run XCTest bundle with simctl

﹥>﹥吖頭↗ 提交于 2019-12-04 05:48:04
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/primus/Build/Products/Debug-iphonesimulator/ios_app.app/ios_app" export SIMCTL_CHILD