课堂PPT
PPT地址
pom
依赖
<properties>
<!--对应解析-->
<jackson.version>2.13.1</jackson.version>
</properties>
<dependencies>
<!-- yaml文件解析-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
yaml解析
datas:
- a: 1
b: 1
result: 2
message: 有效2个整数【1,1】
- a: 98
b: 98
result: 196
message: 有效边界值相加【98,98】
- a: -98
b: 98
result: 0
message: 有效边界值相加【-98,98】
- a: 98
b: -98
result: 0
message: 有效边界值相加【98,-98】
- a: -98
b: -98
result: -196
message: 有效边界值相加【-98,-98】
- a: 100
b: 0
result: 0
message: 无效边界值相加【100,0】
- a: -100
b: -1
result: 0
message: 无效边界值相加【-100,-1】
- a: 2
b: 100
result: 0
message: 无效边界值相加【2,100】
- a: 1
b: -100
result: 0
message: 无效边界值相加【1,-100】
动态测试
shell_test_result.yaml
resultList:
- caseName : 'case_1_1'
result : true
- caseName : 'case_1_2'
result : false
- caseName : 'case_2_1'
result : true
- caseName : 'case_2_2'
result : false
- caseName: 'case_1_1'
result: true
- caseName: 'case_1_2'
result: false
- caseName: 'case_2_1'
result: true
- caseName: 'case_2_2'
result: false
- caseName: 'case_1_1'
result: true
- caseName: 'case_1_2'
result: false
- caseName: 'case_2_1'
result: true
- caseName: 'case_2_2'
result: false
并行测试
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.classes.default = same_thread
junit.jupiter.execution.parallel.config.strategy=fixed
junit.jupiter.execution.parallel.config.fixed.parallelism=8
allure-pom依赖
<properties>
<!--allure报告-->
<allure.version>2.17.2</allure.version>
<aspectj.version>1.9.5</aspectj.version>
</properties>
<dependencies>
<!-- allure报告-->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-junit5</artifactId>
<version>${allure.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<!-- <includes>
<include>${test.suite}</include>
</includes>-->
<!--<properties>
<property>
<name>listener</name>
<value>io.qameta.allure.junit5.AllureJunit5</value>
</property>
</properties> -->
<!--<systemProperties>
<property>
<name>allure.results.directory</name>
<value>${project.build.directory}/allure-results</value>
</property>
<property>
<name>junit.jupiter.extensions.autodetection.enabled</name>
<value>true</value>
</property>
</systemProperties>
<reportFormat>plain</reportFormat>-->
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
allure
报告地址
allure.properties
allure.results.directory=target/allure-results
pom
<configuration>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<!--生成allure-result的目录-->
<systemProperties>
<property>
<name>allure.results.directory</name>
<value>./target/allure-results</value>
</property>
</systemProperties>
</configuration>
allure version
<properties>
<allure.cmd.download.url>
https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline
</allure.cmd.download.url>
</properties>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>2.10.0</version>
<configuration>
<reportVersion>${allure.version}</reportVersion>
<allureDownloadUrl>${allure.cmd.download.url}/${allure.version}/allure-commandline-${allure.version}.zip</allureDownloadUrl>
</configuration>
</plugin>
修改allure报告图片
作业
- 数据驱动- yaml文件,对应测试方法参数为对象
- 优化:yaml文件解析,对应测试方法参数使用自定义注解
mvn clean test -Dtest=指定运行测试类 allure:report
- 去下载相关的allure版本,到当前项目的.allure文件夹x
mvn allure:serve