我正在尝试弄清楚如何在我的 TestNG 套件完成后自动构建 Allure 报告。我知道可以通过在测试后手动运行 mvn site
来创建报告,但是如果可以自动生成报告那就太好了。下面是我的 pom.xml 中的 allure 配置
<properties>
<testng.congig>${selenium.suite}</testng.congig>
<aspectj.version>1.7.4</aspectj.version>
<allure.version>1.4.3</allure.version>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
-javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
</argLine>
<suiteXmlFiles>
<suiteXmlFile>target\test-classes\${testng.congig}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-testng-adaptor</artifactId>
<version>${allure.version}</version>
</dependency>
<reporting>
<excludeDefaults>false</excludeDefaults>
<plugins>
<plugin>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-maven-plugin</artifactId>
<version>{latest.version}</version>
</plugin>
</plugins>
</reporting>
最佳答案
测试执行和站点生成在不同的生命周期中运行。
默认生命周期与站点生命周期不同,请参阅 https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
您可以做的只是链接命令:例如mvn install site
或 mvn deploy site-deploy
如果您打算在某处使站点可用。
这将运行测试,然后执行站点生成。
maven 目标与该生命周期中的一个阶段相关。 mvn package
将执行绑定(bind)到某个阶段的所有插件,直到 package
阶段。由于站点生成有其自己的生命周期,我不会将插件执行绑定(bind)到默认生命周期的阶段之一。报告插件通常依赖于已完成的构建。
关于maven - 测试完成后自动构建诱惑报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31511955/