多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] 取最新版本的allure-testng ### maven pom文件里,添加如下内容 ``` <properties> <aspectj.version>1.8.10</aspectj.version> </properties> <dependencies> <dependency> <groupId>io.qameta.allure</groupId> <artifactId>allure-testng</artifactId> <version>LAST_VERSION</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.20</version> <configuration> <argLine> -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" </argLine> <!-- 使allure-results在target文件夹下否则会生成在项目根目录下 --> <workingDirectory>target/</workingDirectory> </configuration> <dependencies> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> </dependencies> </plugin> </plugins> </build> ``` 然后和平时一样运行mvn `mvn clean test` 使用如下命令,可以使Allure的结果生成在 target/allure-results文件夹下,然后生成html报告 并且自动使用web浏览器打开报告 `allure serve target/allure-results` ### Gradle 针对Gradle用户,提供allure-gradle插件,插件自动配置所依赖的jar包 build.gradle ``` buildscript { repositories { jcenter() } dependencies { classpath "io.qameta.allure:allure-gradle:2.3" } } plugins { id 'io.qameta.allure' } allure { version = '2.2.1' autoconfigure = true aspectjweaver = true allureJavaVersion = LATEST_VERSION } ``` 然后运行build文件 `./gradlew clean test` 使用如下命令,Allure报告会生成在build/allure-results文件夹下,生成html的报告并且自动在web浏览器上打开报告 `./gradlew allureServe build/allure-results`