2017-06-03 179 views
-1

我需要使用pom.xml执行并行测试的一些帮助。无法使用POM.xml并行运行testng测试

信息: 我们有一个用于测试电子商务网站的测试自动化框架。 有一个单独的类用于处理所有的webdriver操作和创建具有静态webdriver的实例。

问题:我们能够通过使用pom.xml(fork count)来运行并行测试。而自从我们在框架中引入了testng之后 - >现在我已将testng.xml包含在pom.xml中,现在它不考虑pom配置,只考虑testng配置,并且只打开1个浏览器,而不是3个。让我知道是否有人遇到同样的问题?

Pom.xml - 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com</groupId> 
    <artifactId>test</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>planet.sports.TA</name> 
    <url>http://maven.apache.org</url> 

    <repositories> 
     <repository> 
      <id>sonatype-snapshots</id> 
      <url>https://oss.sonatype.org/content/repositories/snapshots/</url> 
     </repository> 
    </repositories> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>6.9.13.6</version> 
     </dependency> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>cucumber-java</artifactId> 
      <version>1.2.4</version> 
     </dependency> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>cucumber-testng</artifactId> 
      <version>1.2.4</version> 
      <scope>compile</scope> 

     </dependency> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>cucumber-core</artifactId> 
      <version>1.2.4</version> 
     </dependency> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-firefox-driver</artifactId> 
      <version>2.53.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>2.53.1</version> 
     </dependency> 
     <dependency> 
      <groupId>io.appium</groupId> 
      <artifactId>java-client</artifactId> 
      <version>4.1.2</version> 
     </dependency> 
     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.17</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.poi</groupId> 
      <artifactId>poi-ooxml</artifactId> 
      <version>3.9</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.poi</groupId> 
      <artifactId>poi</artifactId> 
      <version>3.11-beta3</version> 
     </dependency> 
     <dependency> 
      <groupId>xml-apis</groupId> 
      <artifactId>xml-apis</artifactId> 
      <version>2.0.2</version> 
     </dependency> 
     <dependency> 
      <groupId>xerces</groupId> 
      <artifactId>xercesImpl</artifactId> 
      <version>2.8.0</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.httpcomponents</groupId> 
      <artifactId>httpclient</artifactId> 
      <version>4.3.6</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.httpcomponents</groupId> 
      <artifactId>fluent-hc</artifactId> 
      <version>4.3.6</version> 
     </dependency> 
     <dependency> 
      <groupId>com.googlecode.gmail4j</groupId> 
      <artifactId>gmail4j</artifactId> 
      <version>0.5-SNAPSHOT</version> 
     </dependency> 
     <dependency> 
      <groupId>org.jsoup</groupId> 
      <artifactId>jsoup</artifactId> 
      <version>1.10.2</version> 
     </dependency> 
     <dependency> 
      <groupId>com.google.api-client</groupId> 
      <artifactId>google-api-client</artifactId> 
      <version>1.22.0</version> 
     </dependency> 
     <dependency> 
      <groupId>com.googlecode.json-simple</groupId> 
      <artifactId>json-simple</artifactId> 
      <version>1.1</version> 
     </dependency> 
    </dependencies> 
    <build> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <version>2.18.1</version> 
        <configuration> 
        <parallel>tests</parallel> 
         <forkCount>5</forkCount> 
         <!-- TestNG suite XML files --> 
         <suiteXmlFiles> 
          <suiteXmlFile>testng.xml</suiteXmlFile> 
         </suiteXmlFiles> 
         <includes> 
          <include>**/Test*.java</include> 
         </includes> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>3.5.1</version> 
        <dependencies> 
         <dependency> 
          <groupId>org.apache.maven.plugins</groupId> 
          <artifactId>maven-compiler-plugin</artifactId> 
          <version>3.5.1</version> 
         </dependency> 
        </dependencies> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-clean-plugin</artifactId> 
        <version>3.0.0</version> 
        <dependencies> 
         <dependency> 
          <groupId>org.apache.maven.plugins</groupId> 
          <artifactId>maven-clean-plugin</artifactId> 
          <version>3.0.0</version> 
         </dependency> 
        </dependencies> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-resources-plugin</artifactId> 
        <version>2.7</version> 
        <dependencies> 
         <dependency> 
          <groupId>org.apache.maven.plugins</groupId> 
          <artifactId>maven-resources-plugin</artifactId> 
          <version>2.7</version> 
         </dependency> 
        </dependencies> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
    </build> 
</project> 


<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> 
<suite name="Custom suite123" verbose="3" parallel="classes" thread-count="3"> 

<test name="test run1" > 
      <classes> 
      <class name="AmazonTest" /> 
      <class name="AddToCartTest" /> 
      <class name="BankPaymentTest" /> 
      </classes> 
</test> 
</suite> 
+0

你在,你使用的是静态Web驱动程序实例开始讲述。这可能是问题所在,因为即使您在testng中设置了并行,但您所有的测试都指向单个Web驱动器实例,因为它是静态的。尝试使用线程本地网络驱动程序。 – Murthi

回答

相关问题