(1)要使用Allure Report,需要先在pom.xml文件中做以下配置
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <aspectj.version>1.8.10</aspectj.version> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.20</version> <configuration> <testFailureIgnore>false</testFailureIgnore> <argLine> -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" </argLine> <properties> <!--allure测试报告用--> <property> <name>listener</name> <value>io.qameta.allure.junit4.AllureJunit4</value> </property> </properties> <!--allure-results生成在target目录下--> <systemProperties> <property> <name>allure.results.directory</name> <value>${project.build.directory}/allure-results</value> </property> </systemProperties> </configuration> <dependencies> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> </dependencies> </plugin> </plugins> </build> <dependencies> <!--allure测试报告--> <dependency> <groupId>io.qameta.allure</groupId> <artifactId>allure-junit4</artifactId> <version>2.13.1</version> <scope>test</scope> </dependency> </dependencies>
(2) 执行"mvn clean test" ,在target目录下会生成"surefire-reports"目录,是测试执行的结果(txt和xml格式的文件),另外还有一个"allure-results"目录,保存了可用allure读取的测试执行结果(json格式文件等)。