XCUITest sharding | Virtual devices

Perfecto supports splitting your test suite into different tests run separately, in parallel on all selected devices. This enables time optimization in seeing and analyzing the test results and shortening the turnaround.

Split tests

The XCUITest  Gradle Plugin supports XCUITest sharding, running each test shard on a separate device. Using the gradle plugin Configuration file:

  • Select a number of devices (either selecting specific parameters or random selection).
  • Configure the shard parameter to true (can be configured in either the Configuration File, build.gradle file, or on the command line).
  • Plugin will split the tests into a number of shards equal to the number of selected devices.
    The following example splits the test into three shards on randomly selected devices:

    Copy
    "numOfDevices": 3,
    "shard": true,
    ...
  • Each shard will run on a separate device and the summary report will identify the index of the shard for that device.

Shard test output

The console output of the plugin will show the tests running on each device - identifying the device, the test class name, method under test, status.

At the completion of the full test bundle, the summary will identify the results for each device, and provide a link to the Report Library listing for the full test. In the Report Library view, each shard will be listed on a separate line.

Copy
Console output for a test bundle split between two devices

[195105c4a066] [iPhone 13 - 15.5] [2023-05-23 04:13:30] Executing test. Shard 2 out of 2

[1934d13e0ce1] [iPhone 13 - 15.5] [2023-05-23 04:13:30] Executing test. Shard 1 out of 2

[195105c4a066] [iPhone 13 - 15.5] [2023-05-23 04:13:43] [PASS] Class: TestUITests.TestUITests, Method: testPositiveCase

[1934d13e0ce1] [iPhone 13 - 15.5] [2023-05-23 04:13:43] [FAIL] Class: TestUITests.SampleTests, Method: testFailure

[195105c4a066] [iPhone 13 - 15.5] [2023-05-23 04:13:44] Execution finished

[1934d13e0ce1] [iPhone 13 - 15.5] [2023-05-23 04:13:46] [PASS] Class: TestUITests.TestUITests, Method: testSample

[1934d13e0ce1] [iPhone 13 - 15.5] [2023-05-23 04:13:58] Execution finished

Test execution finished

-----------------------------------------------------

Total Summary

Results:
Total: 3
Passed: 2
Failed: 1
Skipped: 0

Run successfully on 2 devices

-----------------------------------------------------
Device: iPhone 13 - 15.5
ExecutionId: 195105c4a066
Results:
Total: 1
Passed: 1
Failed: 0
Skipped: 0

-----------------------------------------------------
Device: iPhone 13 - 15.5
ExecutionId: 1934d13e0ce1
Results:
Total: 2
Passed: 1
Failed: 1
Skipped: 0

-----------------------------------------------------
Report url: https://demo.app.perfectomobile.com/reporting/library?tags%5B0%5D%3D=8e1cd3ab-e0e7-429a-9314-b88260594920