我能够实现带有@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 ×1