gpt4 book ai didi

java - Allure 报告不会使用 mvn test -Darguments 生成

转载 作者:行者123 更新时间:2023-12-02 12:21:05 25 4
gpt4 key购买 nike

问题:我使用 allure reporting 在运行一些测试后生成一些报告,当我从 eclipse 中手动运行测试时,allure-results 目录已在/target/allure- 内成功创建结果目录。

但是,当我从命令行调用 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"}

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

仔细观察,特别是当我在 mvn 调用中传入 -Dcucumber.Options 标签时,似乎会覆盖 -Dcucumber.options="--plugin ru.yandex.qatools.allure.cucumberjvm .AllureReporter” 位于 pom.xml 中我的 Surefire 插件

感谢您的宝贵时间,非常感谢您的帮助。

最佳答案

经过一个漫长的上午,我发现了问题,这只是我传递带有标签的 -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。

关于java - Allure 报告不会使用 mvn test -Darguments 生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45779771/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com