{"_id":"590a04f6ed80861900cbc799","project":"55b2d5baa74a380d00e290c4","version":{"_id":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","__v":4,"createdAt":"2017-05-03T16:27:30.085Z","releaseDate":"2017-05-03T16:27:30.085Z","categories":["590a04f3ed80861900cbc738","590a04f3ed80861900cbc739","590a04f3ed80861900cbc73a","590a04f3ed80861900cbc73b","590a04f3ed80861900cbc73c","590a04f3ed80861900cbc73d","590a04f3ed80861900cbc73e","590a04f3ed80861900cbc73f","590a04f3ed80861900cbc740","590a04f3ed80861900cbc741","590a04f3ed80861900cbc742","590a04f3ed80861900cbc743","590a04f3ed80861900cbc744","590a04f3ed80861900cbc745","590a04f3ed80861900cbc746","590a04f3ed80861900cbc747","590a04f3ed80861900cbc748","590a04f3ed80861900cbc749","590a04f3ed80861900cbc74a","590a04f3ed80861900cbc74b","590a04f3ed80861900cbc74c","590a04f3ed80861900cbc74d","59124949de13f61900336a7a","5914b04e7c2c552d008b7104","5914b47242c6a22300b9dc20"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"7.0.0","version":"7"},"user":"55b2d5626862a10d00887af9","__v":0,"parentDoc":null,"category":{"_id":"590a04f3ed80861900cbc741","__v":0,"project":"55b2d5baa74a380d00e290c4","version":"590a04f2ed80861900cbc737","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-07-18T21:24:18.432Z","from_sync":false,"order":10,"slug":"tests","title":"Tests (iOS)"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-03-15T17:46:29.118Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"The buddybuild SDK is a lightweight yet powerful [suite of tools](doc:integrate-sdk) that integrates seamlessly into your application. Amongst the many features the SDK provides, you can use the buddybuild SDK to record video of your UI tests as they execute.\n\nHere are the step-by-step instructions to configure the SDK in your UI tests target:\n\n##Step 1: Install the buddybuild SDK\n\nThe SDK needs to be integrated into your main app prior to configuring video recording for your UI tests target.\n\nWe highly recommend using the [**automatic** buddybuild SDK integration](doc:integrate-sdk#section-step-2-install-the-sdk) right from your dashboard. However, if you wish to install the buddybuild SDK **manually**, follow [these steps](doc:sdk-integration).\n\n##Step 2: Get the latest version\n\nFollow [these instructions](doc:integrate-sdk#section-update-the-sdk) to update the SDK on your local machine.\n\n##Step 3: Add framework dependencies to your UI test target\n\n* Open your project in Xcode.\n* Highlight your project in the 'Project Navigator'.\n* Select your target.\n* Select the 'Build Phases' tab.\n* Open 'Link Binaries With Libraries' expander.\n* Repeat for each of the ​**AssetsLibrary**, ​**BuddyBuildSDK**, **CoreTelephony**​, **CoreText**, **CoreMedia**, **AVFoundation**, **CoreVideo**, **QuartzCore** and **SystemConfiguration**​​ frameworks:\n  * Click the + button.\n  * Select the required framework name\n  * Click 'Add'\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/c7517b7-1.png\",\n        \"1.png\",\n        1500,\n        861,\n        \"#e2e2e0\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n##Step 4 (Swift only): Include the SDK in your UI test target's Bridging Header \n\nMake sure you have a bridging header in your UI tests target in **Build Settings** in Xcode.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/4c14208-bridging-header-edited.png\",\n        \"bridging-header-edited.png\",\n        1500,\n        316,\n        \"#1860af\"\n      ]\n    }\n  ]\n}\n[/block]\nIf 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.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/024f44f-2.png\",\n        \"2.png\",\n        1500,\n        745,\n        \"#f1f1f0\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n**Include the SDK by adding the following line to your bridging header:**\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <BuddyBuildSDK/BuddyBuildSDK.h>\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n##Step 5: Initialize the buddybuild SDK\n\nAdd the `uiTestsDidReceiveRemoteNotification` call in your app delegate's **didReceiveRemoteNotification** method.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {\\n\\tBuddyBuildSDK.uiTestsDidReceiveRemoteNotification(userInfo)\\n\\t// Initial implemetation below\\n}\",\n      \"language\": \"swift\",\n      \"name\": \"Swift\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {\\n    [BuddyBuildSDK uiTestsDidReceiveRemoteNotification:userInfo];\\n    // Initial implemetation below\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nIf you haven't already implemented **didReceiveRemoteNotification** in your app delegate, you'll need to create it.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"**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.\",\n  \"title\": \"Important\"\n}\n[/block]\n##Step 6: Configure your UI test cases.\n\n###Start video recording for your UI test cases\nAdd the following line **after** each **XCUIApplication().launch()** (generally called in the `setUp` function), call in your UI tests codebase. This will start recording the video right after your app is launched by the UI test case.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"...\\nXCUIApplication().launch()\\nBuddyBuildSDK.startUITests()\\n...\",\n      \"language\": \"swift\",\n      \"name\": \"Swift\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"...\\n[[[XCUIApplication alloc] init] launch];\\n[BuddyBuildSDK startUITests];\\n...\",\n      \"language\": \"objectivec\",\n      \"name\": \"Objective-C\"\n    }\n  ]\n}\n[/block]\n###Stop video recording for your UI test cases\nAdd the following line **before** each **super.tearDown** call in your UI tests codebase. This will stop the video recording and save the file at the end of each UI test case.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"override func tearDown() {\\n\\tBuddyBuildSDK.stopUITests()\\n\\tsuper.tearDown()\\n}\",\n      \"language\": \"swift\",\n      \"name\": \"Swift\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)tearDown {\\n\\t[BuddyBuildSDK stopUITests];\\n  [super tearDown];\\n}\",\n      \"language\": \"objectivec\",\n      \"name\": \"Objective-C\"\n    }\n  ]\n}\n[/block]\n##Step 7: Verify - Run your UI tests locally in Xcode\n\nRun 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.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"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.\",\n      \"language\": \"text\",\n      \"name\": \"When running on a physical device\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"2015-10-05 15:33:24.562 myAwesomeApp[25126:526527] BuddybuildSDK : Disabled in the simulator\",\n      \"language\": \"text\",\n      \"name\": \"When running in a simulator\"\n    }\n  ]\n}\n[/block]\n##Step 8: Make sure Tests are enabled in buddybuild\n\nGo 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. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/b5a0b27-3.png\",\n        \"3.png\",\n        1500,\n        466,\n        \"#dadddf\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n##Step 9: Commit and push\n\nCommit the change and push the changes to your repo to add the buddybuild SDK.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"git add - -all\\ngit commit -m 'Adding buddybuild SDK for UI tests video recording'\\ngit push\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nThat'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!","excerpt":"","slug":"configure-ui-tests-video-recording-ios","type":"basic","title":"Configure your iOS UI tests for Video Replay"}

Configure your iOS UI tests for Video Replay


The buddybuild SDK is a lightweight yet powerful [suite of tools](doc:integrate-sdk) that integrates seamlessly into your application. Amongst 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](doc:integrate-sdk#section-step-2-install-the-sdk) right from your dashboard. However, if you wish to install the buddybuild SDK **manually**, follow [these steps](doc:sdk-integration). ##Step 2: Get the latest version Follow [these instructions](doc:integrate-sdk#section-update-the-sdk) 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' [block:image] { "images": [ { "image": [ "https://files.readme.io/c7517b7-1.png", "1.png", 1500, 861, "#e2e2e0" ], "sizing": "full" } ] } [/block] ##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. [block:image] { "images": [ { "image": [ "https://files.readme.io/4c14208-bridging-header-edited.png", "bridging-header-edited.png", 1500, 316, "#1860af" ] } ] } [/block] 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. [block:image] { "images": [ { "image": [ "https://files.readme.io/024f44f-2.png", "2.png", 1500, 745, "#f1f1f0" ], "sizing": "full" } ] } [/block] **Include the SDK by adding the following line to your bridging header:** [block:code] { "codes": [ { "code": "#import <BuddyBuildSDK/BuddyBuildSDK.h>", "language": "objectivec" } ] } [/block] ##Step 5: Initialize the buddybuild SDK Add the `uiTestsDidReceiveRemoteNotification` call in your app delegate's **didReceiveRemoteNotification** method. [block:code] { "codes": [ { "code": "func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {\n\tBuddyBuildSDK.uiTestsDidReceiveRemoteNotification(userInfo)\n\t// Initial implemetation below\n}", "language": "swift", "name": "Swift" } ] } [/block] [block:code] { "codes": [ { "code": "- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {\n [BuddyBuildSDK uiTestsDidReceiveRemoteNotification:userInfo];\n // Initial implemetation below\n}", "language": "objectivec" } ] } [/block] If you haven't already implemented **didReceiveRemoteNotification** in your app delegate, you'll need to create it. [block:callout] { "type": "info", "body": "**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.", "title": "Important" } [/block] ##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 codebase. This will start recording the video right after your app is launched by the UI test case. [block:code] { "codes": [ { "code": "...\nXCUIApplication().launch()\nBuddyBuildSDK.startUITests()\n...", "language": "swift", "name": "Swift" } ] } [/block] [block:code] { "codes": [ { "code": "...\n[[[XCUIApplication alloc] init] launch];\n[BuddyBuildSDK startUITests];\n...", "language": "objectivec", "name": "Objective-C" } ] } [/block] ###Stop video recording for your UI test cases Add the following line **before** each **super.tearDown** call in your UI tests codebase. This will stop the video recording and save the file at the end of each UI test case. [block:code] { "codes": [ { "code": "override func tearDown() {\n\tBuddyBuildSDK.stopUITests()\n\tsuper.tearDown()\n}", "language": "swift", "name": "Swift" } ] } [/block] [block:code] { "codes": [ { "code": "- (void)tearDown {\n\t[BuddyBuildSDK stopUITests];\n [super tearDown];\n}", "language": "objectivec", "name": "Objective-C" } ] } [/block] ##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. [block:code] { "codes": [ { "code": "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.", "language": "text", "name": "When running on a physical device" } ] } [/block] [block:code] { "codes": [ { "code": "2015-10-05 15:33:24.562 myAwesomeApp[25126:526527] BuddybuildSDK : Disabled in the simulator", "language": "text", "name": "When running in a simulator" } ] } [/block] ##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. [block:image] { "images": [ { "image": [ "https://files.readme.io/b5a0b27-3.png", "3.png", 1500, 466, "#dadddf" ], "sizing": "full" } ] } [/block] ##Step 9: Commit and push Commit the change and push the changes to your repo to add the buddybuild SDK. [block:code] { "codes": [ { "code": "git add - -all\ngit commit -m 'Adding buddybuild SDK for UI tests video recording'\ngit push", "language": "shell" } ] } [/block] 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!