【问题标题】:Running Selenium WebDriver test in parallel with NUnit3与 NUnit3 并行运行 Selenium WebDriver 测试
【发布时间】:2016-02-05 14:53:53
【问题描述】:

我正在使用 NUnit3 的 Parallelizable 属性来运行我的 Selenium WebDriver 测试,但测试总是按顺序运行。我的机器的工人数量默认为 4。我有 2 个固定装置,如下所示:

    [TestFixture]
    [Parallelizable(ParallelScope.Fixtures)]
    public class SeleniumTest1
    {
        [Test]
        public void Is_Title_Correct()
        {
            IWebDriver driver = new FirefoxDriver();
            driver.Navigate().GoToUrl("http://www.google.nl");
            string actualTitle = driver.Title;
            string expectedTitle = "Google";
            Assert.AreEqual(expectedTitle, actualTitle, "title is not correct");
            driver.Quit();
        }
   }

我怎样才能让它并行运行,以便它可以同时打开两个浏览器?

【问题讨论】:

  • 您是否还有其他 TextFixtures 或者您仅在显示的 1 个下进行了所有测试?
  • 我还有一个测试夹具:[TestFixture] [Parallelizable(ParallelScope.Fixtures)] public class SeleniumTest2 { [Test] public void Is_Title_Correct() { IWebDriver driver = new FirefoxDriver(); driver.Navigate().GoToUrl("http://www.google.nl"); string actualTitle = driver.Title; string expectedTitle = "Google"; Assert.AreEqual(expectedTitle, actualTitle, "title is not correct"); driver.Quit(); } }
  • 您是否尝试过同时运行这 2 个不同的 TestFixture?
  • 我正在使用 Nunit3 控制台运行器运行两个 TestFixture。

标签: selenium selenium-webdriver parallel-processing nunit-3.0


【解决方案1】:

这取决于您用于运行测试的单元测试运行器。我的问题还没有解决方案。但只是为了让您了解如何进一步进行......

如果您使用 (1) Visual Studio NUnit 测试适配器 - 它显然还不支持 NUnit 3; (2) ReSharper 单元测试运行器仅最新版本 (10) 支持 NUnit 3 - 我会先尝试从 VS 并行运行单元测试; (3) NUnit 3 控制台单元测试运行器 - 当我查看它时,它还没有准备好并行运行单元测试。现在应该可以了,看看吧。

同样,它的主要思想是寻找一个可以并行运行测试的工具。

【讨论】:

  • 我正在使用 Nunit3 控制台运行器。测试是按顺序运行的。
  • 我尝试使用 ReSharper 10 运行我的测试,现在测试正在并行运行。谢谢!!
  • @Megha 请将答案标记为已回答。谢谢你。我也尝试过 NUnit 3 Console - 它还没有准备好并行运行测试。您可以在官方文档中阅读:github.com/nunit/dev/wiki/Framework-Parallel-Test-Execution
  • @Megha 您如何使用 Resharper 10 运行测试?它对我不起作用:(
  • @DenisKoreyba - 检查 ReSharper > 选项 > 程序集数。您可以将其更改为机器上的处理器数量。我也可以与 NUnit3 Console runner 并行运行测试,我只是将 Web 驱动程序更改为 Chrome Web 驱动程序。我仍然需要弄清楚为什么它没有与 firefox 网络驱动程序并行运行。
最近更新 更多