第一步需要新建Maven项目,编写代码实现自动化,在IDEA控制台输入 mvn clean test
第二步 在Pom.xml配置对应的Allured jar和配置对应的Allured配置,生成本地Allured
<dependency> <groupId>io.qameta.allure</groupId> <artifactId>allure-testng</artifactId> <version>2.13.1</version> <scope>test</scope> </dependency>
防止有乱码 <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>
<build> <plugins> <plugin> <!-- maven-surefire-plugin 配合testng.xml执行测试用例的maven插件 --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <!-- 测试失败后,是否忽略并继续测试 --> <testFailureIgnore>true</testFailureIgnore> <suiteXmlFiles> <suiteXmlFile>testNg.xml</suiteXmlFile> </suiteXmlFiles> <systemProperties> <property> <!-- 配置 allure 结果存储路径 --> <name>allure.results.directory</name> <value>${project.build.directory}/allure-results</value> </property> </systemProperties> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>8</source> <target>8</target> </configuration> </plugin> </plugins> </build>
第三步:在控制台执行 mvn io.qameta.allure:allure-maven:serve