2017-06-03 177 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

回答

相關問題