命令格式:
allure [option] [command] [command options]
allure --help 帮助
allure --version 查看版本信息
allure serve 生成在线版本的测试
allure generate <allure-result中间文件> -o 输出目录 (默认路径:allure-report)
引入依赖
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hogwarts</groupId> <artifactId>AllureDemo2</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>RELEASE</version> <scope>test</scope> </dependency> <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest</artifactId> <version>2.2</version> <scope>test</scope> </dependency> <dependency> <groupId>io.qameta.allure</groupId> <artifactId>allure-junit5</artifactId> <version>2.13.6</version> <scope>test</scope> </dependency> </dependencies> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> <aspectj.version>1.8.10</aspectj.version> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M5</version> <configuration> <includes> <include>**/*Test.java</include> </includes> </configuration> </plugin> </plugins> </build> </project>
代码示例
import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; public class DemoTest { @Test public void demo1() { assert 1 + 1 == 2; } @Test public void demo2() { assertThat(2, equalTo(2)); } @Test public void demo3() { assertThat(2, equalTo(0)); } }
pom.xml右键:open in / terminal,命令执行:
mvn clean test
查看在线allure报告:
方式一
allure serve ./target/surefire-reports
方式二
allure serve ./allure-results
target目录下的数据当执行mvn clean时会自动清楚,这样生成的报告就是最新的,allure-results下要手动删除
// 运行所有用例
mvn clean test
// 运行指定一个文件,或者多个文件,以逗号隔开
mvn clean package -Dtest=<文件名1> test
mvn clean package -Dtest=<文件名1>,<文件名2>,... test
测试报告位置
- 测试结果保存在两个位置
- target/surefire-reports/
- allure-results/
标签:allure,Test,Allure,clean,常用命令,test,org,mvn From: https://www.cnblogs.com/ixtao/p/17658148.html