其他分享
首页 > 其他分享> > Junit六大注解使用

Junit六大注解使用

作者:互联网

参考博客:https://blog.csdn.net/weixin_39651356/article/details/103585674 JUnit单元测试六大常用 - @Test、@Before、@After、@BeforeClass、@AfterClass、@Ignore
Junit6大注解
@Test:表示当前方法是一个测试方法,- 修饰非静态方法
@BeforeClass
@AfterClass
@Before
@After
@Ignore:用在类上,所有测试注解修饰的方法都不会执行;用在@Test测试方法上才有效,表示该测试方法将被忽略(执行测试类,测试类可能有多个@Test方法)

junit4 junit5 特点
@BeforeClass @BeforeAll 最先运行,且只运行一遍 - 修饰静态方法
@AfterClass @AfterAll 所有注解运行完毕,才最后运行,只运行一遍 - 修饰静态方法
@Before @BeforeEach 紧随在@Test运行之前,有多少个@Test就运行多少遍 - 同@Test共存亡 - 修饰非静态方法
@After @AfterEach 紧随在@Test运行之后,有多少个@Test就运行多少遍 - 同@Test共存亡 - 修饰非静态方法

标签:六大,静态方法,AfterClass,修饰,Test,注解,Junit,运行
来源: https://www.cnblogs.com/powerfulTime/p/16468572.html