我使用硒电网使用TestNG测试网站。测试码,我从硒IDE输出工作正常。我的问题是,在测试运行顺序的,不平行的。

下面是代码:

public class test{

    @BeforeMethod
    public void startSession()
    {
        ThreadSafeSeleniumSessionStorage.startSeleniumSession("localhost",4444,"*firefox","url" );
    }

    @AfterMethod(alwaysRun = true)
    public void closeSession() throws Exception
    {
      ThreadSafeSeleniumSessionStorage.closeSeleniumSession();
    }

    @DataProvider(name = "test")
    public Object[][] test()
    {
        return new Object[][]{
        {test1,null},
        {test2,null},
        };
}

 @Test(dataProvider = "test")
 void testen(String value1, String value2) throws Exception
  {
     ThreadSafeSeleniumSessionStorage.session().open("url");
     .
     .
     .
     .
     .
     ThreadSafeSeleniumSessionStorage.session().waitForPageToLoad("30000");
    }

}

我的testng.xml看起来像这样:

套件线程计数= “5” skipfailedinvocationCounts = “假” 冗长= “1” 名称= “命令行套件” 的junit = “假” 平行= “方法” 注释= “JDK”

我在做什么错了?该测试仅在一个硒RC,尽管多于一个的启动。

我希望有人能帮助我,这是非常重要的。

谢谢!

有帮助吗?

解决方案

升级到TestNG的5.11,它实现并行数据提供者。在以前的版本总是调用的所有数据提供者调用在同一线程...

- 塞德里克

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top