小编Meh*_*taş的帖子

Junit5-jupiter 所有测试套件 @BeforeAll @AfterAll 不起作用

before 和 after 方法在 JUnitPlatform 中不起作用。

代码如下。

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.runner.RunWith;

@RunWith(JUnitPlatform.class)
@SelectClasses({
        MyControllerTest.class
})
public class AdminAppTest {

    @BeforeAll
    public static void setUp() {
        System.out.println("setting up");
    }

    @AfterAll
    public static void tearDown() {
        System.out.println("tearing down");
    }
}
Run Code Online (Sandbox Code Playgroud)

我只想在方法之前和之后运行。

谢谢

junit integration-testing spring-boot spring-boot-test junit-jupiter

6
推荐指数
2
解决办法
1万
查看次数