XCTest
  • 02 May 2023
  • 2 Minutes to read
  • Dark
    Light

XCTest

  • Dark
    Light

Article summary

XCUITest is a mobile automation framework provided by Apple that helps user write UI tests for your iOS applicationsThis guide will help you run your first XCUI test on pCloudy.

Pre-requisites

  1. User should be registered on pCloudy platform. Sign up for a free trial or purchase a plan.
  2. Need access to .zip file
    If User do not have .ipa files and are looking to simply try App Automate, user can download our sample zip file
  3. To download sample zip file click the link below.

ArchiveXCTestPRod(1).zip

  1. Upload the sample zip file in the MyData section manually or using API.
  2. Upload your iOS app (.ipa) file on the pCloudy platform using an API request.

curl --location --request POST URL format:

curl -X POST -F "file=@/File_Path" -F "source_type=raw" -F "token=authToken" -F "filter=filter" <Cloud URL>/api/upload_file

Steps To Execute XCtest

After the user uploads the app and test suite on the pCloudy platform, Use the below mentioned API's
1.Get Device list for iOS-This api is used to get iOS device list

Endpoint: request POST: {{URL}}/api/devices

Sample request

{
"token": "jmxbd3jvrdt74nzcjc43ccth",
"duration": 15,
"platform": "ios",
"available_now": "true"
}

Sample response

{
"result": {
    "token": "jmxbd3jvrdt74nzcjc43ccth",
    "code": 200,
    "models": [
        {
            "index": 1,
            "full_name": "Apple_iPhoneSE_Ios_11.2.5_58ce2",
            "id": 799,
            "alias_name": "58ce2",
            "model": "iPhoneSE",
            "display_name": "iPhone SE",
            "platform": "ios",
            "version": "11.2.5",
            "cpu": "Dual Core",
            "bucket": 3,
            "manufacturer": "Apple",
            "mobile_number": "",
            "dpi": "",
            "url": "https://device.pcloudy.com/device_images/small/iPhoneSE.png",
            "ram": 2048,
            "resolution": "640x1136",
            "display_area": 4,
            "available": true
        }
    ]
}

}

2.Book Device API
This api book the devices for XCTest automation execution.

EndPoint : {{URL}}/api/automationbooking    

Sample request

{
"token":"s85zmqdv3wfxgrp9x3btynbn ","devices":[783],"booking_duration": "30","automation_type": "XCUITest"}
Sample response
{
"result": "Devices are reserved successfully for the automation execution",
"statuscode": "200",
"data": {
"automationId": 440916
}
}

3.Initialize Automation
This API initiates the XCTest on devices for that test suite. The test suite you had to upload by using upload API which is available in Generic API.
}/api/api/initautomation

Sample request 
{ "token":"s85zmqdv3wfxgrp9x3btynbn","automationId": "440916","test_suite": "ArchiveXCTestPRod(1).zip"}

Sample response

{
"statuscode": 200,
"result": "Automation initiated successfully..."

}

4.Start Device Services
This API helps to initialize device services on the device like device log, performance log, and session video recording.

EndPoint : {{URL}}/api/startdeviceservices

Sample request

{"token":"s85zmqdv3wfxgrp9x3btynbn","automationId": "440925","startDeviceLogs": "true","startPerformanceData": "true","startSessionRecording": "true"}

Sample response

{
"statuscode": 200,
"result": "Device logs started successfully,Performance data started successfully,Session video recording started successfully"

}

  1. Automation Report Shareable Link
EndPoint : {{URL}}/api/api/getAutomationShareableReportLink
This API helps to share the automation reports to team.

Note: Change the format of shreable link to JSON format.
Sample request

 {"token":"s85zmqdv3wfxgrp9x3btynbn","rid":"440925"}

Sample response

{
"result": {
    "token": "s85zmqdv3wfxgrp9x3btynbn",
    "shareableLink": "https://device.pcloudy.com/execution_report/0?key=j8z8qjfjxmwqvcby73k4fn8p"
}

}

  1. Release Device
    This API helps you to release the XCTest automation devices.
EndPoint : {{URL}}/api/api/automationrelease    

Sample request

{"token":"s85zmqdv3wfxgrp9x3btynbn","automationId": "440925"}

View test results

After you start an XCUI test-suite execution visit your Reports section to view your test results


Was this article helpful?

What's Next