Skip to content

Files

Latest commit

95dd1b2 · Sep 29, 2017

History

History
217 lines (181 loc) · 5.4 KB

configure_ui_tests_video_recording.adoc

File metadata and controls

217 lines (181 loc) · 5.4 KB

Configure your iOS UI tests for Video Replay

The buddybuild SDK is a lightweight yet powerful suite of tools that integrates seamlessly into your application. Among the many features the SDK provides, you can use the buddybuild SDK to record video of your UI tests as they execute.

Here are the step-by-step instructions to configure the SDK in your UI tests target:

Step 1: Install the buddybuild SDK

The SDK needs to be integrated into your main app prior to configuring video recording for your UI tests target.

We highly recommend using the automatic buddybuild SDK integration right from your dashboard. However, if you wish to install the buddybuild SDK manually, follow these steps.

Step 2: Get the latest version

Follow these instructions to update the SDK on your local machine.

Step 3: Add framework dependencies to your UI test target

  1. Open your project in Xcode.

  2. Highlight your project in the Project Navigator.

  3. Select your target.

  4. Select the Build Phases tab.

  5. Open Link Binaries With Libraries expander.

  6. Repeat for each of the AssetsLibrary, BuddyBuildSDK, CoreTelephony, CoreText, CoreMedia, AVFoundation, CoreVideo, QuartzCore and SystemConfiguration frameworks:

    1. Click the + button.

    2. Select the required framework name.

    3. Click the Add button.

    The Project Navigator view in Xcode

Step 4: Initialize the buddybuild SDK

Add the uiTestsDidReceiveRemoteNotification call in your app delegate’s didReceiveRemoteNotification method.

Important

If you have an application:didReceiveRemoteNotification:fetchCompletionHandler method, it takes priority over the didReceiveRemoteNotification method; place the uiTestsDidReceiveRemoteNotification call there.

Swift
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
  BuddyBuildSDK.uiTestsDidReceiveRemoteNotification(userInfo)
  // Initial implementation below
}
Objective-C
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    [BuddyBuildSDK uiTestsDidReceiveRemoteNotification:userInfo];
    // Initial implementation below
}

If you haven’t already implemented didReceiveRemoteNotification in your app delegate, you need to create it.

Important

uiTestsDidReceiveRemoteNotification only runs in buddybuild while your UI tests run. It does not run when you build from Xcode on your local machine, on real iOS devices, on TestFlight, or on App Store installs.

Step 5: Configure your UI test cases.

Start video recording for your UI test cases

Add the following line after each XCUIApplication().launch() (generally called in the setUp function), call in your UI tests code base. This will start recording the video right after your app is launched by the UI test case.

Swift
...
XCUIApplication().launch()
BuddyBuildSDK.startUITests()
...
Objective-C
...
[[[XCUIApplication alloc] init] launch];
[BuddyBuildSDK startUITests];
...

Stop video recording for your UI test cases

Add the following line before each super.tearDown call in your UI tests code base. This will stop the video recording and save the file at the end of each UI test case.

Swift
override func tearDown() {
  BuddyBuildSDK.stopUITests()
  super.tearDown()
}
Objective-C
- (void)tearDown {
  [BuddyBuildSDK stopUITests];
  [super tearDown];
}

Step 6: Verify - Run your UI tests locally in Xcode

Run your UI tests locally (⌘+U) in Xcode. In the output pane you should see the following log line, which indicates that the buddybuild SDK has been successfully integrated.

When running on a physical device
2015-10-05 15:34:48.693 myAwesomeApp[25126:526527] BuddybuildSDK : Successfully integrated. Feedback tool, crash reporting and other features are disabled for local builds. Please build with https://dashboard.buddybuild.com to enable.
When running in a simulator
2015-10-05 15:33:24.562 myAwesomeApp[25126:526527] BuddybuildSDK : Disabled in the simulator

Step 7: Make sure Tests are enabled in buddybuild

Go to the buddybuild dashboard and make sure that Tests are enabled in buddybuild. This setting can be found in the 'App Settings' of your app.

The Tests setting in the buddybuild dashboard

Step 8: Commit and push

Commit the change and push the changes to your repo to add the buddybuild SDK.

git add - -all
git commit -m 'Adding buddybuild SDK for UI tests video recording'
git push

That’s it! Your code push will be picked up by buddybuild. All subsequent builds of your App will now record a video for each of your UI tests!