重复用例

一个小小测试 / 2023-08-25 / 原文

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;

public class RepeatedExampleTest {
//    @Test // 如果要使用重复测试,就可以不使用@Test
//    @RepeatedTest(10) // 注解内需要传递控制重复次数的参数
    // value 表示要重复几次
    // displayName 对应执行用例的displayname,
    // currentRepetition 第几次重复
    // totalRepetitions 代表总共要重复的次数
    @RepeatedTest(value = 3, name = "{displayName} {currentRepetition}/{totalRepetitions}")
    @DisplayName("重复测试")
    void hogwarts(){
        System.out.println("1111");
    }
}