霍格沃兹测试开发学社
assertAll(heading, executables)
聚合所有断言
heading
executables
src/test/resources
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: 无效边界值相加【99,0】
- a: -100
b: -1
result: 0
message: 无效边界值相加【-99,-1】
- a: 2
b: 100
result: 0
message: 无效边界值相加【2,99】
- a: 1
b: -100
result: 0
message: 无效边界值相加【1,-99】
Add.java
AData.java
<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>
源MethodSource
stream流为实体类的流
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
命令行验证版本
添加相关依赖到pom文件
编写相关测试用例
安装allure
命令行输入allure --version
查看版本号
<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
基本注解注解 | 说明 |
---|---|
@DisplayName |
显示名称;类和方法上的注解 |
@Description |
测试方法详细描述 |
@Step |
定义对应的步骤 |
Attachment |
动态添加附件 |
allure.results.directory=target/allure-results
<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.addAttachment("动态上传图片", "image/jpg",new FileInputStream("./logo.jpg"),".jpg");