Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Nov 27, 2019 13:43

If you have been struggling with parallelization in NUnit or wondering how to create a proper parallelizable Perfecto project, this article is for you.

This article describes the fundamental difference in Parallelism in terms of testing 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. Perfecto recommends using the first method because it produces more reliable results for multi-device/platforms/brands testing.

On this page:

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:

    [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:

    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:

[assembly: LevelOfParallelism(3)]

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