Alluer2 报告用例优先级简介
- 应用场景:用例执行时,希望按照严重级别执行测试用例。
- 解决:可以为每个用例添加一个等级的装饰器,用法:
@Severity
。
Alluer2 报告用例优先级介绍
- Allure 对严重级别的定义分为 5 个级别:
- Blocker级别:中断缺陷(客户端程序无响应,无法执行下一步操作)。
- Critical级别:临界缺陷( 功能点缺失)。
- Normal级别:普通缺陷(数值计算错误)。
- Minor级别:次要缺陷(界面错误与UI需求不符)。
- Trivial级别:轻微缺陷(必输项无提示,或者提示不规范)。
Alluer2 报告中添加用例优先级
- 使用
@Severity
注解添加。
@Severity(SeverityLevel.)
package com.junit5.allure2casedesciption_l2;
import io.qameta.allure.Severity;
import io.qameta.allure.SeverityLevel;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertEquals;
@DisplayName("用例等级划分的验证")
//@Severity(SeverityLevel.BLOCKER)//代表这个类下的所有测试用例都是者一个等级
//测试方法的用例等级优先级大于声明的测试类上的声明的等级
public class SeverityTest {
@Test
@DisplayName("Blocker级别的优先级")
@Severity(SeverityLevel.BLOCKER)
public void testSeverity01() throws IOException {
String input = "test data";
ByteArrayInputStream inputStream = new ByteArrayInputStream(input.getBytes());
byte[] buffer = new byte[1024];
int byteRead = inputStream.read(buffer);
inputStream.close();
assertEquals("test data",new String(buffer,0,byteRead));
}
@Test
@DisplayName("CRITICAL级别的优先级")
@Severity(SeverityLevel.CRITICAL)
public void testSeverity02() throws IOException {
String input = "test data";
ByteArrayInputStream inputStream = new ByteArrayInputStream(input.getBytes());
byte[] buffer = new byte[1024];
int byteRead = inputStream.read(buffer);
inputStream.close();
assertEquals("test data",new String(buffer,0,byteRead));
}
@Test
@DisplayName("NORMAL级别的优先级")
// @Severity(SeverityLevel.NORMAL)
public void testSeverity03() throws IOException {
String input = "test data";
ByteArrayInputStream inputStream = new ByteArrayInputStream(input.getBytes());
byte[] buffer = new byte[1024];
int byteRead = inputStream.read(buffer);
inputStream.close();
assertEquals("test data",new String(buffer,0,byteRead));
}
@Test
@DisplayName("MINOR级别的优先级")
@Severity(SeverityLevel.MINOR)
public void testSeverity04() throws IOException {
String input = "test data";
ByteArrayInputStream inputStream = new ByteArrayInputStream(input.getBytes());
byte[] buffer = new byte[1024];
int byteRead = inputStream.read(buffer);
inputStream.close();
assertEquals("test data",new String(buffer,0,byteRead));
}
@Test
@DisplayName("TRIVIAL级别的优先级")
@Severity(SeverityLevel.TRIVIAL)
public void testSeverity05() throws IOException {
String input = "test data";
ByteArrayInputStream inputStream = new ByteArrayInputStream(input.getBytes());
byte[] buffer = new byte[1024];
int byteRead = inputStream.read(buffer);
inputStream.close();
assertEquals("test data",new String(buffer,0,byteRead));
}
}