2013-01-02 70 views
1

我需要组织我的应用程序的功能测试。我需要使用硒网格+ testng + webdriver。正如我发现设置项目的好方法是在eclipse中使用maven。我已经设置了硒网格,但不知道如何适当地设置将与所有这些工具一起使用的maven项目。也许有人有经验或有用的链接。在此先感谢Selenium Grid + TestNG + Maven

回答

2

如果你想使用maven testng测试,你需要设置maven surefire插件来启动你在testng中定义的测试套件。

首先,你需要在你的依赖TestNG的,所以将它添加到您的pom.xml文件:

<dependencies> 
    [...] 
    <dependency> 
     <groupId>org.testng</groupId> 
     <artifactId>testng</artifactId> 
     <version>6.3.1</version> 
     <scope>test</scope> 
    </dependency> 
    [...] 
</dependencies> 

然后,你需要告诉万无一失正在使用的测试套件,突然想到想它是suite.xml:

<plugins> 
    [...] 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.13</version> 
     <configuration> 
      <suiteXmlFiles> 
      <suiteXmlFile>testng.xml</suiteXmlFile> 
      </suiteXmlFiles> 
     </configuration> 
     </plugin> 
    [...] 
</plugins> 

正如我所看到的,您使用的网格,所以如果你想在并行运行它们,你可以做你的pom.xml文件的插件部分如下:

</plugins> 
    [...] 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.13</version> 
     <configuration> 
      <parallel>methods</parallel> 
      <threadCount>10</threadCount> 
     </configuration> 
     </plugin> 
    [...] 
</plugins> 

当然,您需要在该pc上至少运行一个selenium hub,并且至少要有一个客户端。 确保您的测试配置为使用selenium grid2而不是本地webdriver运行。

问候,

圣地亚哥