2017-06-03 11 views
-1

pom.xmlを使用して並列テストを実行するには、いくつかの助けが必要です。POM.xmlでperlでtestngテストを実行できない

情報: 私たちは、電子商取引のウェブサイトをテストするためのテスト自動化フレームワークを持っています。 静的webdriverを持つすべてのwebdriver操作とインスタンス作成を処理するための別のクラスがあります。

質問:pom.xml(fork count)を使用するだけで、並列テストを実行できました。私たちのフレームワークにtestngを導入して以来、 - >今、私はtestng.xmlをpom.xmlに含めていますが、今はpomの設定を考慮せず、testngの設定だけを考慮し、3つではなく1つのブラウザを開きます。もし誰かが同じ問題に直面したことがあれば教えてください。

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

はあなたが、あなたは静的なウェブ・ドライバ・インスタンスを使用している最初に言われた:

これはあなたにいくつかの方向性を与えるかもしれません。これは問題である可能性があります。なぜなら、testngで並列に設定しても、すべてのテストが静的なので、単一のWebドライブインスタンスを指しているからです。スレッドローカルWebドライバを使用してみてください。 – Murthi

答えて

0

Murthiで指摘したように、あなたは(たとえば)@BeforeClass注釈中のブラウザインスタンスを分離する必要があり、この方法は、各スレッドは、独自のドライバーを持っており、独立して機能することができるようになります。テストのマルチスレッド化は、単なるパラメータ変更ではなく、設計アプローチです。 https://wiki.saucelabs.com/display/DOCS/Parallel+Testing+in+Java+with+Maven+and+TestNG

関連する問題