Tuesday, March 15, 2022

Parameters of parallel testing

 Let's pay attention to the parameters:


batches is an array with your tests. It should be used if you want to explicitly specify which tests should be run on each simulator. In the array, you must specify the path to your test according to the following scheme: Test target name/ Class name with tests/ Test name.


destination is an argument where you can specify a specific: simulator, physical device, mac.


Let's analyze destination in more detail:

  • The full name of the simulator, which can be found in “Devices and Simulators”
  • UDID of your device. UDID can be obtained using the simctl utility
  • iOS version, tvOS, watchOS. Specify the version supported by Xcode


A few examples to understand destination:


We indicate the iPhone X simulator on OS version 13.1.

-destination 'platform=iOS Simulator,name=iPhone X,OS=13.1'


Specify the simulator using the simulator's UDID.

-destination 'platform=iOS Simulator,id=6DC4A7BA-EA7F-40D6-A327-A0A9DF82F7F6'


The most important

Parallelizing tests allows you to speed up your tests by several times!

You can do this locally through xcode, but it will divide them by class, not by an equal number.

To parallelize tests on ci, use the multi_scan plugin for fastlane. The implementation is very simple, and there is a lot of profit.


Test parallelization is a simple and very useful tool to speed up your tests, which I recommend to everyone.

Parallelizing tests using Fastlane


As an example of evaluating results on multi_scan, this is an application for fastlane.


Imagine a situation where we have 40 tests and we want to run them on 4 simulators.


multi_scan(
project: 'yourProjectPath',
scheme: 'SwiftRadioUITests',
fail_build: false,
device: 'iPhone 8',
batch_count: 4,
parallel_testrun_count: 4
)


We are interested in the parameters:


batch_count - how many parts to share the total number of tests to run in the simulator. For example, you have 40 tests and we put a value of 4, then each simulator runs 10 tests.


parallel_testrun_count is the number of simulators to run tests in parallel. There are no restrictions on the number here, but I advise you to use common sense and protest how many simulators your build agent can withstand.


Specify cases of disease in two parameters.


Now let's imagine an example in which we want to separate other tests for each simulator.

Parameters of parallel testing

 Let's pay attention to the parameters: batches is an array with your tests. It should be used if you want to explicitly specify which t...