1

I am trying to run my tests on Parallel mode but it is running sequentially and not parallelly. I found one question link here but the solution provided in the same(Neil and Charlie, both) is also not working for me.

Here is my base class:-

[TestFixtureSource(typeof(TestDataProvider), nameof(TestDataProvider.BrowsersToRunWith))]
[TestFixture]
public class CrossBrowser
{
    public IWebDriver driver;
    public string Browsername { get; }


    public CrossBrowser(string browserName)
    {
        Browsername = browserName;

    }

    [SetUp]
    public void LaunchBrowser()
    {


        if (Browsername.ToLower().Contains("chrome"))
        {
            driver = new ChromeDriver();
        }
        else
        {
            driver = new FirefoxDriver();
        }

    }

TestDataProvider Class:-

class TestDataProvider
{
    internal static IEnumerable BrowsersToRunWith
    {            
        get
        {
           String[] browser = { "Chrome", "FireFox" };
            foreach (string b in browser)
            {
                yield return b;
            }
        }
    }
}

Test Class1:-

[Parallelizable(ParallelScope.Self)
public class UT1 : CrossBrowser
{
    
    public UT1(String browserName) : base(browserName)
    {
        Console.WriteLine("Browser is " + browserName);
    }

    [Test]
    public void OpenGoogle()
    {
        driver.Url = "http://google.com";
        driver.Quit();
    }
        
}

Test Class2:-

[Parallelizable(ParallelScope.Self)]

public class UT2 : CrossBrowser
{
    
    public UT2(String browserName) : base(browserName)
    {
        Console.WriteLine("Browser is " + browserName);
    }

    [Test]
    public void OpenGoogle()
    {
        driver.Url = "http://google.com";
        driver.Quit();
    }
        
}

Test Explorer:-

enter image description here

When I am running all the tests, it is running one by one and not on a parallel mode. Am I missing anything? Please suggest. Thanks

Naseem
  • 911
  • 5
  • 18
  • 48
  • What did you try from that link ? – Caius Jard Sep 19 '21 at 05:35
  • I was trying to do parallel execution on a Single class first but as mentioned in that link "Unit tests will not run in parallel if they are in the same class. If you have 3 separate test classes, it should work.". I created 2 different class and then tried but still the same issue. – Naseem Sep 19 '21 at 07:04
  • So, you read Neil's one line answer, it didn't work out.. You then returned to the question and read Charlie's massive and in-depth answer that started out with "Neil's answer is wrong.." and decided to read more closely what Charlie had to say? – Caius Jard Sep 19 '21 at 07:06
  • Apologies for not checking that solution as it was not marked as Answered but after you pointed it out, I tried those combinations as well. It's not working for me as well. I have one Fixture in the base class and in the child class, I have mentioned as Parallelscope.Self. I tried adding Parallelscrope.Children in the Base class as well but it also is not working. – Naseem Sep 19 '21 at 10:29
  • Please [edit] your question to include code as plain text. – Greg Burghardt Sep 20 '21 at 14:00
  • 1
    @GregBurghardt - done. Just kept the Test Explorer as an image. Please let me know if you need any more information. – Naseem Sep 22 '21 at 04:23

0 Answers0