2017-11-17 4 views
0

Allureリスナー(https://docs.qameta.io/allure/2.0/#_java)に問題があります。私はパラレルモードでテストを実行することはできません。ureureと並列テストの実行 - 次のテストが始まる前にリスナーが5秒追加されています

public class Parallel { 

    @Test 
    public void test1() throws InterruptedException { 

     Thread.sleep(3000); 
     System.out.println(Calendar.getInstance().getTime()); 
     Assert.assertEquals(1, 1); 
    } 

    @Test 
    public void test2() throws InterruptedException { 

     Thread.sleep(3000); 
     System.out.println(Calendar.getInstance().getTime()); 
     Assert.assertEquals(1, 1); 
    } 

    @Test 
    public void test3() throws InterruptedException { 

     Thread.sleep(3000); 
     System.out.println(Calendar.getInstance().getTime()); 
     Assert.assertEquals(1, 1); 
    } 
} 

スイートクラス:

@RunWith(Suite.class) 
@Suite.SuiteClasses({Parallel.class}) 
public class ParallelSuite { 

} 

テストはMVNを介して実行されている:POMから

mvn clean compile test-compile -DfailIfNoTests=false -Dtest=ParallelSuite test 

並列テスト実行を

Testクラス(クラスコンテンツ)

:ここでのコードは.xml:

私は私が印刷されてしまった。このテストを実行すると

は、[すべてはOKです]:ここ

Fri Nov 17 13:45:07 CET 2017 
Fri Nov 17 13:45:07 CET 2017 
Fri Nov 17 13:45:07 CET 2017 

私はすべての3つのテストが並列に実行されていることがわかります。しかし、私がAllureリスナを有効にすると、すべてのテスト実行が2秒間シフトされます。したがって、テストはパラレルではなく順番に実行されます。ここで

はのpom.xmlからリスナーのための設定です:

<argLine> 
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" 
        </argLine> 
        <properties> 
         <property> 
          <name>listener</name> 
          <value>io.qameta.allure.junit4.AllureJunit4</value> 
         </property> 
        </properties> 

をそしてここで時間がログに記録される出力は次のようになります。

Fri Nov 17 13:55:58 CET 2017 
Fri Nov 17 13:56:03 CET 2017 
Fri Nov 17 13:56:08 CET 2017 

どのようにパラレルモードでテストを実行するためのセットアップアリュールリスナーへ? Allure demo screenshot

答えて

0

魅力的なリスナーは、パラレル実行に影響するはずです。 pom.xmlを完全に共有できますか?

私はあなたのデータをサンプルプロジェクトを作成して、それが正常に動作するようです: https://github.com/letsrokk/stackoverflow-examples/tree/master/allure-junit-parallel

[INFO] Running com.github.letsrokk.suites.Parallel 
Mon Nov 20 16:34:12 CET 2017 
Mon Nov 20 16:34:12 CET 2017 
Mon Nov 20 16:34:12 CET 2017 
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.098 s - in com.github.letsrokk.suites.Parallel 
0
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
      <modelVersion>4.0.0</modelVersion> 

      <groupId>me.fra</groupId> 
      <artifactId>api-tests</artifactId> 
      <packaging>jar</packaging> 
      <version>1.0-SNAPSHOT</version> 
      <name>api-tests</name> 

      <properties> 
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
       <jdk.version>1.8</jdk.version> 
       <aspectj.version>1.8.10</aspectj.version> 
      </properties> 

      <repositories> 
       <repository> 
        <snapshots> 
         <enabled>false</enabled> 
        </snapshots> 
        <id>central</id> 
        <name>Central Repository</name> 
        <url>https://repo.maven.apache.org/maven2</url> 
       </repository> 
      </repositories> 

      <pluginRepositories> 
       <pluginRepository> 
        <releases> 
         <updatePolicy>never</updatePolicy> 
        </releases> 
        <snapshots> 
         <enabled>false</enabled> 
        </snapshots> 
        <id>central</id> 
        <name>Central Repository</name> 
        <url>https://repo.maven.apache.org/maven2</url> 
       </pluginRepository> 
      </pluginRepositories> 

      <dependencies> 
       <!-- https://mvnrepository.com/artifact/junit/junit --> 
       <dependency> 
        <groupId>junit</groupId> 
        <artifactId>junit</artifactId> 
        <version>4.12</version> 
        <scope>test</scope> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured --> 
       <dependency> 
        <groupId>io.rest-assured</groupId> 
        <artifactId>rest-assured</artifactId> 
        <version>3.0.5</version> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt --> 
       <dependency> 
        <groupId>io.jsonwebtoken</groupId> 
        <artifactId>jjwt</artifactId> 
        <version>0.9.0</version> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec --> 
       <dependency> 
        <groupId>commons-codec</groupId> 
        <artifactId>commons-codec</artifactId> 
        <version>1.11</version> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-junit4 --> 
       <dependency> 
        <groupId>io.qameta.allure</groupId> 
        <artifactId>allure-junit4</artifactId> 
        <version>2.0-BETA19</version> 
        <scope>test</scope> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-maven --> 
       <dependency> 
        <groupId>io.qameta.allure</groupId> 
        <artifactId>allure-maven</artifactId> 
        <version>2.9</version> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 --> 
       <dependency> 
        <groupId>org.slf4j</groupId> 
        <artifactId>slf4j-log4j12</artifactId> 
        <version>1.7.25</version> 
        <scope>test</scope> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 --> 
       <dependency> 
        <groupId>org.apache.commons</groupId> 
        <artifactId>commons-collections4</artifactId> 
        <version>4.1</version> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/org.json/json --> 
       <dependency> 
        <groupId>org.json</groupId> 
        <artifactId>json</artifactId> 
        <version>20171018</version> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/org.antlr/ST4 --> 
       <dependency> 
        <groupId>org.antlr</groupId> 
        <artifactId>ST4</artifactId> 
        <version>4.0.8</version> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/com.jcabi/jcabi-matchers --> 
       <dependency> 
        <groupId>com.jcabi</groupId> 
        <artifactId>jcabi-matchers</artifactId> 
        <version>1.4</version> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> 
       <dependency> 
        <groupId>org.projectlombok</groupId> 
        <artifactId>lombok</artifactId> 
        <version>1.16.18</version> 
        <scope>provided</scope> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/org.awaitility/awaitility --> 
       <dependency> 
        <groupId>org.awaitility</groupId> 
        <artifactId>awaitility</artifactId> 
        <version>3.0.0</version> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/org.fluttercode.datafactory/datafactory --> 
       <dependency> 
        <groupId>org.fluttercode.datafactory</groupId> 
        <artifactId>datafactory</artifactId> 
        <version>0.8</version> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/pl.pragmatists/JUnitParams --> 
       <dependency> 
        <groupId>pl.pragmatists</groupId> 
        <artifactId>JUnitParams</artifactId> 
        <version>1.1.0</version> 
        <scope>test</scope> 
       </dependency> 
       <!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-ec2 --> 
       <dependency> 
        <groupId>com.amazonaws</groupId> 
        <artifactId>aws-java-sdk-ec2</artifactId> 
        <version>1.11.232</version> 
       </dependency> 
      </dependencies> 

      <build> 
       <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> 
       <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory> 
       <outputDirectory>${project.basedir}/target/classes</outputDirectory> 
       <testOutputDirectory>${project.basedir}/target/test-classes</testOutputDirectory> 
       <resources> 
        <resource> 
         <directory>${project.basedir}/src/main/resources</directory> 
        </resource> 
       </resources> 
       <testResources> 
        <testResource> 
         <directory>${project.basedir}/src/test/resources</directory> 
        </testResource> 
       </testResources> 
       <directory>${project.basedir}/target</directory> 
       <finalName>api-tests-1.0-SNAPSHOT</finalName> 
       <plugins> 
        <plugin> 
         <artifactId>maven-compiler-plugin</artifactId> 
         <version>3.6.1</version> 
         <executions> 
          <execution> 
           <id>default-compile</id> 
           <phase>compile</phase> 
           <goals> 
            <goal>compile</goal> 
           </goals> 
          </execution> 
          <execution> 
           <id>default-testCompile</id> 
           <phase>test-compile</phase> 
           <goals> 
            <goal>testCompile</goal> 
           </goals> 
          </execution> 
         </executions> 
         <configuration> 
          <source>${jdk.version}</source> 
          <target>${jdk.version}</target> 
         </configuration> 
        </plugin> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-surefire-plugin</artifactId> 
         <version>2.20</version> 
         <executions> 
          <execution> 
           <id>default-test</id> 
           <phase>test</phase> 
           <goals> 
            <goal>test</goal> 
           </goals> 
          </execution> 
         </executions> 
         <configuration> 
          <testFailureIgnore>false</testFailureIgnore> 
          <parallel>suitesAndMethods</parallel> 
          <forkCount>1</forkCount> 
          <useUnlimitedThreads>true</useUnlimitedThreads> 
          <testFailureIgnore>false</testFailureIgnore> 
          <argLine> 
           -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" 
          </argLine> 
          <properties> 
           <property> 
            <name>listener</name> 
            <value>io.qameta.allure.junit4.AllureJunit4</value> 
           </property> 
          </properties> 
          <systemProperties> 
           <property> 
            <name>allure.results.directory</name> 
            <value>${basedir}/target/allure-results</value> 
           </property> 
           <property> 
            <name>allure.link.tms.pattern</name> 
            <value>https://demohq.atlassian.net/browse/{}</value> 
           </property> 
           <property> 
            <name>allure.link.issue.pattern</name> 
            <value>https://app.asana.com/0/{}/f</value> 
           </property> 
          </systemProperties> 
         </configuration> 
         <dependencies> 
          <dependency> 
           <groupId>org.aspectj</groupId> 
           <artifactId>aspectjweaver</artifactId> 
           <version>${aspectj.version}</version> 
          </dependency> 
         </dependencies> 
        </plugin> 
        <plugin> 
         <groupId>io.qameta.allure</groupId> 
         <artifactId>allure-maven</artifactId> 
         <version>2.9</version> 
        </plugin> 
       </plugins> 
      </build> 
     </project> 

ここでいっぱいのpom.xmlです。それがあなたを助けることを願っています。

関連する問題