Getting Started with XCUITest

What Is XCUITest?

Launched in 2015 by Apple as part of Xcode, XCUITest is a UI testing framework built on top of Apple's XC test framework. XCUITest allows you to create and execute UI, performance, and unit tests for iOS applications. It is a popular tool that many development teams favor for testing native iOS apps.

On the Kobiton UI, the automation settings will return the capabilities needed to connect to iOS devices and run an XCUITest from your testing environment. 

 

Running an XCUITest Using Automation Settings

To run an XCUITest on Kobiton:

  1. From your Kobiton portal's device list, navigate to the desired iOS device and click the ellipsis icon  vertical-ellipses-icon.png.
  2. Click on Automation Settings.mceclip0.png
  3. In the Automation Settings box, fill in the following testing capabilities:
    • Framework: select XCUITest
    • Language: select from Java, .Net C#, NodeJS, Ruby, Python, PHP
    • Session Name: default name is "Automation test session", but it can be customized
    • Description: optional session description
    • Session Timeout: default timeout is 60 minutes, but can be changed to designated time
    • User Team: defaults to user's default user team, but can be changed if executing user is a member of multiple groups
    • Device Team: defaults to device's default device team, but click to open the dropdown for other available teams
    • Use specific device: check the box beside this feature to enable the use of only the specified iOS device
    • Clean up device on exit: check the box beside this feature to enable the device clean-up plan you've selected for your org to run on this device once the test completes 
    • App: select which app access method you prefer: either upload an application with a URL or an application on the Kobiton App Repository, as described below
      • Hybrid/Native from URL
        • Application URL
      • Hybrid/Native from apps
        • Select App from Apps Repo
    • Test Runner: enter the URL for the test.apk or use click Upload Test Runner to upload a test.apk file 
    • API Key: populates with the default API keymceclip2.png
  4. Use the copy to clipboard icon to copy the generated desired capabilities. mceclip3.png
  5. Paste the capabilities to your scripted test. 

Example:

The JavaScript example below will use XCUITest to make a connection to the device through the Kobiton portal. To view this project in Github, click here

const request = require('request')

const username = 'Kobiton.Username';
const apiKey = 'de3135e2-754d-4245-9d5b-51c00b60162e';
const configuration = {
sessionName: 'Automation test session',
sessionDescription: 'Running a basic XCUITest script',
udid: '4321f3564db153a4a274d3a918963a2c4393618b',

groupId: 905, // Group: Kobiton Inc.
deviceGroup: 'KOBITON',
app: 'https://kobiton-devvn.s3-ap-southeast-1.amazonaws.com/apps-test/XCUITestSample.ipa',
testRunner: 'https://kobiton-devvn.s3-ap-southeast-1.amazonaws.com/apps-test/XCUITestSampleUITestRunner.ipa',
testFramework: 'XCUITEST',
sessionTimeout: 30,

tests: []
}

const headers {
'Content-Type': 'application/json',
'Authorization': 'encodeAuth',
'Accept': 'application/json'
}

const body {
configuration
}

request ({
url: 'https://api.kobiton.com/hub/session'
json: true,
method: 'Post',
body,
headers,
}, function (err, response, body) {
if (err) return console.error ('Error:', err)
console.log ('Response body:', body)
})
Was this article helpful?
0 out of 0 found this helpful