Parallelization of Perfecto Tests in NUnit
If you have been struggling with parallelization in NUnit or wondering how to create a proper parallelizable Perfecto project, this article is for you.
There is a the fundamental difference in parallelism in terms of testing that you will learn by way of the following scenarios:
- Scenario A: All tests are being parallelized on multiple different devices, where each device runs all tests.
- Scenario B: All tests are being parallelized among multiple different devices, where the devices run different tests.
Here is a link to the project on GitHub: https://github.com/PerfectoMobileSA/Parallelization-of-Tests-in-NUnit
Let’s look at these scenarios in detail. Consider using the first method because it produces more reliable results for multi-device/platforms/brands testing.
Scenario A
In this scenario, all tests are being parallelized on multiple different devices, where each device runs all tests.
To set up this scenario:
-
To have all tests run on all devices, ensuring multilayer results, set all of the different devices that you want to test on as Fixtures, as follows:
Copy[TestFixture(Device.Device1)]
[TestFixture(Device.Device2)]
[TestFixture(Device.Device3)]This tells the framework that all tests inherited by this class are run on all devices. For more information on Fixtures, see https://nunit.org/docs/2.6.3/testFixture.html.
-
Inherit this class as per:
Copypublic class TestSuite1 : TestBase
You will immediately spot the difference in the Test Explorer the moment you build your solution.
Scenario B
In this scenario, all tests are being parallelized among multiple different devices, where the devices run different tests. If you start to write your application and want some simple testing, this second, more immature method is for you. Runs runs faster on multiple devices and provides you with results.
To set up this scenario:
Set the capabilities to be the criteria for device pick and the level of Parallelism as per:
[assembly: LevelOfParallelism(3)]
This ensures that your test runs on different devices simultaneously and asynchronously, as the following graphic shows: