3
【代码】JUnit的生命周期方法
source link: https://feiju12138.github.io/2022/11/06/JUnit%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E6%96%B9%E6%B3%95/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
【代码】JUnit的生命周期方法
2022-11-06
1
JUnit的生命周期方法
初始化方法
- 被注解
@BeforeEach
标注的方法,会在每次测试类执行开始之前会自动执行 - 被注解
@AfterEach
标注的方法,会在每次测试类执行结束之后会自动执行
package com;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class Tests {
@Test
public void test() {
...
}
@BeforeEach
public void init() {
...
}
@AfterEach
public void destroy() {
...
}
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK