1.下载allure-commandline压缩包,解压缩配置环境变量
下载地址:https://github.com/allure-framework/allure2/releases/tag/2.13.1
验证allure是否成功,cmd输入allure
2.maven pom.xml中设置,只需要allure-testng的版本号替换为实际的版本号
<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> </configuration> <dependencies> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> </dependencies> </plugin> </plugins> </build>
3.如果想要自定义allure-results的生成位置,可以根据以下2种方式进行修改
3.1新建一个allure.properties放在resources目录下
allure.results.directory=target/allure-results 实际想要生成的目录
3.2通过pom文件设置
在maven-surefire-plugin中configuration下设置systemPropertyVariables
<systemPropertyVariables> <allure.results.directory>./test-output/allure-results</allure.results.directory> </systemPropertyVariables>
4.右键 run as maven test
运行Maven项目build时出现No compiler is provided in this environment解决方法: