使用NUnit v3 alpha如何在注意到[Parallelizable(ParallelScope.Fixtures)]之后让我的TestFixtures并行运行

时间:2015-02-10 20:37:41

标签: parallel-testing nunit-3.0

使用NUnit v3我已将[Parallelizable(ParallelScope.Fixtures)]添加到2个单独的[TestFixtures]。

积极的是他们运行,否定的是他们没有并行运行,是否缺少需要在代码中注明的语法?我看起来并且目前处于alpha状态,他们支持并行运行TestFixtures而不是Fixture中的测试。

但是我没有看到我的测试并行运行。我的目标是Sauce Labs。

[TestFixture, Description("IE10, Launch url, verify elements, log in, verify landing page")]

//will run test fixtures in parallel

[Parallelizable(ParallelScope.Fixtures)]

//second series of tests to run in parallel
[TestFixture, Description("IE9, Launch url, verify elements, log in, verify landing page")]

//will run test fixtures in parallel

[Parallelizable(ParallelScope.Fixtures)]

每个测试线性运行并成功运行,在TestFixture级别运行以实现我的目的。但是我觉得我在这里错过了一个概念。

任何帮助都可以帮助我弄清楚为什么这不起作用。

感谢 任

2 个答案:

答案 0 :(得分:1)

你的两个TestFixtures做同样的事吗?如果他们可能只尝试一个TestFixture类并具有两个TestFixture属性。

[TestFixture("chrome", "WIN8")]
[TestFixture("firefox", "WIN8")]
[Parallelizable(ParallelScope.Fixtures)]
public class RDTestFixture
{
    public RDTestFixture(string browser, string os)
    {   
        DesiredCapabilities capability = new DesiredCapabilities();
        capability.SetCapability("browserName", browser);
        capability.SetCapability("platform", os);
        driver = new RemoteWebDriver(new Uri("http://10.168.88.131:4444/wd/hub/"), capability); //address of the GRID hub
        driver.Manage().Window.Maximize();
     }

这只是直接在硒网格上运行,而不是Sauce Labs,两者并行运行。

答案 1 :(得分:0)

以下是我如何使用nunit-console并行运行selenium测试。

  • 更新了测试项目以使用最新的NUnit程序集
  • 更新了过时的属性。您可以找到完整列表here
  • 为每个类添加以下行,我想并行运行:

    [TestFixture]
    [Parallelizable(ParallelScope.Fixtures)]
    
  • 使用以下命令行运行NUnit控制台:

    nunit-console.exe C:\Path\My.Tests.dll --include=Selenium --result=TestResult.xml;format=nunit2 --workers=4
    
相关问题