霍格沃兹测试开发学社
ceshiren.com
https://docs.qameta.io/allure/#_junit_5
五种级别 :
BLOCKER("blocker"), 阻塞缺陷(功能未实现,无法下一步)
CRITICAL("critical"), 严重缺陷(功能点缺失)
NORMAL("normal"), 一般缺陷(边界情况,格式错误)
MINOR("minor"), 次要缺陷(界面错误与ui需求不符)
TRIVIAL("trivial"); 轻微缺陷(必须项无提示,或者提示不规范)
import io.qameta.allure.Link;
import io.qameta.allure.Severity;
import io.qameta.allure.SeverityLevel;
import org.junit.jupiter.api.Test;
public class AllureSeverityTest {
...
@Test
@Severity(SeverityLevel.NORMAL)
public void normalTest() {
assert 1 + 1 == 2;
}
@Test
@Severity(SeverityLevel.CRITICAL)
public void criticalTest() {
assert 1 + 1 == 2;
}
...
}
public class AllureStepTest {
@Test
public void someTest() throws Exception {
//Some code...
Allure.step("步骤1",this::step1Logic);
Allure.step("步骤2",this::step2Logic);
assertThat(1,equalTo(1));
//Some more assertions...
}
@Step("This is step 1")
private void step1Logic() {
// Step1 implementation
System.out.println("步骤1");
}
@Step("This is step 2")
private void step2Logic() {
// Step2 implementation
System.out.println("步骤2");
}
}
public class AllureAttachmentTest {
@Test
public void addattachTest(){
// 添加文本展示
Allure.addAttachment("My attachment", "My attachment content");
// 添加截图展示
try {
Allure.addAttachment("add picture", "image/png",new FileInputStream("/Users/juanxu/Documents/图片/专属海报.jpeg"),".jpg");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}