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.

Important: This document includes references to a third-party product, NUnit. The user interface and usage of third-party products are subject to change without notice. For the latest published information about NUnit, see https://docs.nunit.org.

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:

  1. 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.

  2. Inherit this class as per:

    Copy
    public class TestSuite1 : TestBase

    You will immediately spot the difference in the Test Explorer the moment you build your solution.

    With the Fixtures:

    Without the Fixtures:

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:

Copy
[assembly: LevelOfParallelism(3)]

This ensures that your test runs on different devices simultaneously and asynchronously, as the following graphic shows: