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

  • Open your project in Xcode.

  • Highlight your project in the 'Project Navigator'.

  • Select your target.

  • Select the 'Build Phases' tab.

  • Open 'Link Binaries With Libraries' expander.

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

    • Click the + button.

    • Select the required framework name

    • Click 'Add'

      1.png

Step 4 (Swift only): Include the SDK in your UI test target’s Bridging Header

Make sure you have a bridging header in your UI tests target in Build Settings in Xcode.

bridging header edited.png

If you don’t have a bridging header, the fastest way to create one is to temporarily add a new .m file to your project. Xcode will then prompt you to create a bridging header. After it’s created you can delete that .m file.

2.png

Include the SDK by adding the following line to your bridging header:

#import 

Step 5: Initialize the buddybuild SDK

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

Swift
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
  BuddyBuildSDK.uiTestsDidReceiveRemoteNotification(userInfo)
  // Initial implementation below
}
- (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’ll need to create it.

Note

Important

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

Step 6: 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 7: 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 8: 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.

3.png

Step 9: 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!

results matching ""

    No results matching ""