Search code examples
c#seleniumnunit

Limit number of parallel threads in NUnit Project


I am running selenium test in parallel in an NUnit project and want to limit the number of test that are run at a time

Solution I found says to specify:[assembly: LevelOfParallelism(N)] to AssemblyInfo.cs, but my NUnit project does not have an AssemblyInfo.cs

I want to limit number of selenium test run executed in parallel in NUnit project


Solution

  • The documentation says might, it is not mandatory to be in AssemblyInfo.cs:

    The following code, which might be placed in AssemblyInfo.cs


    You could add [assembly:LevelOfParallelism(3)] to your test fixture .cs file. Take a look more about assembly attribute here.

    using System;
    
    [assembly: LevelOfParallelism(3)]
    
    namespace YourNamespace
    {
        [TestFixture]
        public class YourTextFixture
        {
        }
    }