小编Mee*_*era的帖子

@BeforeAll方法为非静态

我能够实现带有@BeforeAll注释的非静态设置方法。似乎只被调用一次,所以工作正常。我有点困惑,因为文档@BeforeAll指出该方法必须是静态的。请解释。

@TestMethodOrder(OrderAnnotation.class)
@SpringJUnitWebConfig(locations = { "classpath:service.xml" }) 
@TestInstance(Lifecycle.PER_CLASS)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented 
@Inherited 
public class MyTest
{
    @BeforeAll
    public void setup() throws Exception {...}
}
Run Code Online (Sandbox Code Playgroud)

junit5

0
推荐指数
2
解决办法
910
查看次数

标签 统计

junit5 ×1