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

6
  • What did you try from that link ? Commented Sep 19, 2021 at 5: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. Commented Sep 19, 2021 at 7: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? Commented Sep 19, 2021 at 7: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. Commented Sep 19, 2021 at 10:29
  • 1
    @GregBurghardt - done. Just kept the Test Explorer as an image. Please let me know if you need any more information. Commented Sep 22, 2021 at 4:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.