Allure 报告不会通过 mvn test -Darguments 生成

Allure reporting does not generate with mvn test -Darguments

问题: 我正在使用诱惑报告在 运行 一些测试后生成一些报告,当我 运行 从 eclipse 中手动测试在 /target/allure-results 目录中成功创建了 allure-results 目录。

然而,当我从命令行调用 maven 后传递一些参数时,像这样:

call mvn clean 
call mvn test -Dbrowser=Chrome -DseleniumEnvironment=local -Dreporttogenerate=censoredconfigsetting -Dcucumber.options="--tags @censoredTag 

注意:mvn clean test 会从命令行生成 allure-reports,为什么我的论点会破坏它?

相反,它在 /target 中创建了一个 /cucumber/results/ 目录,我很困惑为什么会有所不同,这些标签似乎不会有太多问题,我怀疑这可能是我的问题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>org.kore</groupId>
   <artifactId>kore-automation</artifactId>
   <version>0.0.1</version>
   <packaging>jar</packaging>
   <name>kore-automation</name>
   <properties>
      <maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
      <build.number>${maven.build.timestamp}/${platform}/${platformVersion}/${browser}/${browserVersion}</build.number>
      <reports.directory>${project.build.directory}/../reports/${build.number}</reports.directory>
      <cucumber.tags>~@ignore</cucumber.tags>
      <!-- Needed for allure-maven-plugin to specify report version -->
      <aspectj.version>1.8.4</aspectj.version>
   </properties>
   <dependencies>
      <dependency>
         <groupId>org.seleniumhq.selenium</groupId>
         <artifactId>selenium-java</artifactId>
         <version>3.0.0</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
         <version>1.8.0-alpha2</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-log4j12</artifactId>
         <version>1.8.0-alpha2</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.hamcrest</groupId>
         <artifactId>hamcrest-junit</artifactId>
         <version>2.0.0.0</version>
      </dependency>
      <dependency>
         <groupId>org.seleniumhq.selenium</groupId>
         <artifactId>selenium-server</artifactId>
         <version>3.0.0</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>ru.yandex.qatools.allure</groupId>
         <artifactId>allure-cucumber-jvm-adaptor</artifactId>
         <version>1.6.3</version>
      </dependency>
      <dependency>
         <groupId>info.cukes</groupId>
         <artifactId>cucumber-java</artifactId>
         <version>1.2.4</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.12</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>com.google.guava</groupId>
         <artifactId>guava</artifactId>
         <version>16.0.1</version>
      </dependency>
      <dependency>
         <groupId>net.masterthought</groupId>
         <artifactId>cucumber-reporting</artifactId>
         <version>3.7.0</version>
      </dependency>
      <dependency>
         <groupId>com.microsoft.sqlserver</groupId>
         <artifactId>mssql-jdbc</artifactId>
         <version>6.1.0.jre8</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.codehaus.jackson</groupId>
         <artifactId>jackson-core-asl</artifactId>
         <version>1.9.13</version>
      </dependency>
      <dependency>
         <groupId>com.github.temyers</groupId>
         <artifactId>cucumber-jvm-parallel-plugin</artifactId>
         <version>2.1.0</version>
      </dependency>
   </dependencies>
   <profiles>
      <profile>
         <id>read-properties</id>
         <activation>
            <file>
               <exists>src/test/resources/config.properties</exists>
            </file>
         </activation>
         <build>
            <plugins>
               <plugin>
                  <groupId>org.codehaus.mojo</groupId>
                  <artifactId>properties-maven-plugin</artifactId>
                  <version>1.0-alpha-2</version>
                  <executions>
                     <execution>
                        <phase>validate</phase>
                        <goals>
                           <goal>read-project-properties</goal>
                        </goals>
                        <configuration>
                           <files>
                              <file>src\test\resources\config.properties</file>
                           </files>
                        </configuration>
                     </execution>
                  </executions>
               </plugin>
            </plugins>
         </build>
      </profile>
   </profiles>
   <build>
      <plugins>
         <plugin>
            <groupId>com.github.temyers</groupId>
            <artifactId>cucumber-jvm-parallel-plugin</artifactId>
            <version>4.1.0</version>
            <executions>
               <execution>
                  <id>generateRunners</id>
                  <phase>generate-test-sources</phase>
                  <goals>
                     <goal>generateRunners</goal>
                  </goals>
                  <configuration>
                     <!-- Mandatory -->
                     <!-- comma separated list of package names to scan for glue code -->
                     <glue>
                        <package>webDriver</package>
                        <package>censored</package>
                        <package>censored</package>
                        <package>testRunner</package>
                     </glue>
                     <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
                     <!-- The directory, which must be in the root of the runtime classpath, containing your feature files.  -->
                     <featuresDirectory>src/test/java/</featuresDirectory>
                     <!-- Directory where the cucumber report files shall be written  -->
                     <!-- cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir-->
                     <!-- comma separated list of output formats json,html,rerun.txt -->
                     <!-- format>json</format-->
                     <!-- CucumberOptions.strict property -->
                     <!-- strict>true</strict>-->
                     <!-- CucumberOptions.monochrome property -->
                     <monochrome>true</monochrome>
                     <!-- The tags to run, maps to CucumberOptions.tags property you can pass ANDed tags like "@tag1","@tag2" and ORed tags like "@tag1,@tag2,@tag3" -->
                     <tags />
                     <!-- If set to true, only feature files containing the required tags shall be generated. -->
                     <filterFeaturesByTags>false</filterFeaturesByTags>
                     <!-- Generate TestNG runners instead of default JUnit ones. -->
                     <useTestNG>false</useTestNG>
                     <!-- The naming scheme to use for the generated test classes.  One of 'simple' or 'feature-title' -->
                     <namingScheme>simple</namingScheme>
                     <!-- The class naming pattern to use.  Only required/used if naming scheme is 'pattern'.-->
                     <namingPattern>Parallel{c}IT</namingPattern>
                     <!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario.  FEATURE generates a runner per feature. -->
                     <parallelScheme>FEATURE</parallelScheme>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
               <encoding>UTF-8</encoding>
               <source>1.7</source>
               <target>1.7</target>
               <compilerArgument>-Werror</compilerArgument>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.18.1</version>
         </plugin>
         <plugin>
            <groupId>ru.yandex.qatools.allure</groupId>
            <artifactId>allure-maven-plugin</artifactId>
            <version>2.6</version>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
               <testFailureIgnore>false</testFailureIgnore>
               <argLine>-javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
                -Dcucumber.options="--plugin ru.yandex.qatools.allure.cucumberjvm.AllureReporter"</argLine>
               <properties>
                  <property>
                     <name>listener2</name>
                     <value>/core-automation/src/test/java/testRunner/CustomAllureListener</value>
                  </property>
               </properties>
               <forkCount>10</forkCount>
               <reuseForks>true</reuseForks>
               <includes>
                  <include>**/*IT.class</include>
               </includes>
            </configuration>
            <dependencies>
               <dependency>
                  <groupId>org.aspectj</groupId>
                  <artifactId>aspectjweaver</artifactId>
                  <version>${aspectj.version}</version>
               </dependency>
            </dependencies>
         </plugin>
      </plugins>
      <pluginManagement>
         <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
            <plugin>
               <groupId>org.eclipse.m2e</groupId>
               <artifactId>lifecycle-mapping</artifactId>
               <version>1.0.0</version>
               <configuration>
                  <lifecycleMappingMetadata>
                     <pluginExecutions>
                        <pluginExecution>
                           <pluginExecutionFilter>
                              <groupId>org.codehaus.mojo</groupId>
                              <artifactId>properties-maven-plugin</artifactId>
                              <versionRange>[1.0-alpha-2,)</versionRange>
                              <goals>
                                 <goal>read-project-properties</goal>
                              </goals>
                           </pluginExecutionFilter>
                           <action>
                              <ignore />
                           </action>
                        </pluginExecution>
                        <pluginExecution>
                           <pluginExecutionFilter>
                              <groupId>com.github.temyers</groupId>
                              <artifactId>cucumber-jvm-parallel-plugin</artifactId>
                              <versionRange>[4.1.0,)</versionRange>
                              <goals>
                                 <goal>generateRunners</goal>
                              </goals>
                           </pluginExecutionFilter>
                           <action>
                              <ignore />
                           </action>
                        </pluginExecution>
                     </pluginExecutions>
                  </lifecycleMappingMetadata>
               </configuration>
            </plugin>
         </plugins>
      </pluginManagement>
   </build>
</project>

我注意到当生成并行 .IT 文件到 运行 我的并行测试时,它们各自引用:

plugin = {"json:C:/Users/sy/git/censor/censor/target/cucumber-parallel/1.json"}

仍然有点困惑,因为当 运行ning 在 eclipse 中时 -> 运行 as: Maven Build... -> clean test 我没有这些 json 文件已创建,只有在像 mvn args 这样的命令中传递时,我才会得到它们

仔细观察,特别是当我在 mvn 调用中为标签传递 -Dcucumber.Options 时,似乎覆盖了 [=36= 中我的 surefire 插件中的 -Dcucumber.options="--plugin ru.yandex.qatools.allure.cucumberjvm.AllureReporter" ]

感谢您的宝贵时间,我们将不胜感激。

经过一个漫长的早晨,我发现了问题,这只是我传递的 -Dcucumber.options 标签覆盖了 allurereporter 的 maven surefire argLine。

已通过 运行 以下内容修复:

call mvn clean test -Dbrowser=Chrome -DseleniumEnvironment=local -Dcucumber.Options="--plugin ru.yandex.qatools.allure.cucumberjvm.AllureReporter --tags @censoredtag"
call mvn allure:report 

并从我的 maven surefire 插件中删除 -Dcucumber.Options argLine。