【问题标题】:Data Provider object and parallel test exclusion in testNGtestNG 中的数据提供者对象和并行测试排除
【发布时间】:2016-01-10 09:06:10
【问题描述】:

我正在使用一个数据提供程序,它用越来越多的数字初始化“x”,以便与我的@test 一起使用。这意味着测试将为每个“x”运行一次。我想在并行线程上运行测试,这样会花费更少的时间,例如:在 10 个浏览器上并行运行相同的测试)。 我添加了 @DataProvider(name = "dataProvider", 并行 = true) 但它没有帮助,似乎根本不起作用。
有另一种方法可以做到这一点吗?

@DataProvider(name = "dataProvider", parallel = true)
public Object[][] xData() throws Exception {
    Object[][] result = new Object[31293][1];
    for (int x = 0; x < 31293; x++) {
        result[x] = new Object[]
                {x};
    }
    return result;
}

@Test(dataProvider = "dataProvider")
public void Requirement(int x) throws Exception {
System.out.println("Testing with x=" + x);
    }

谢谢!

【问题讨论】:

    标签: testing parallel-processing automation testng


    【解决方案1】:

    您需要在 TestNG.xml 中指定parallel = true,而不是在类中。

    <suite name="Parallel test suite" parallel="methods" thread-count="2">
    

    参考:-

    http://www.seleniumeasy.com/testng-tutorials/parallel-execution-of-test-methods-in-testng
    

    还有

    如何使用并行:-

    http://testng.org/doc/documentation-main.html#parallel-suites
    

    希望对你有帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-04
      • 1970-01-01
      • 2020-01-13
      相关资源
      最近更新 更多