1理论知识
(1)@Test
注解的测试方法,项目打包时不会与项目一同打包
(2)@BeforeAll
被注解的(静态)方法将当前类中的所有@Test方法前执行一次
(3)@AfterAll
被注解的(静态)方法将当前类中的所有@Test方后执行一次
(4)@BeforeEach
被注解的方法将当前类中的每个@Test方法前执行
(5)@AfterEach
被注解的方法将当前类中的每个@Test方法后执行
(6) @DisplayName
给测试用例起别名
(7)@Disabled
禁用
2实战操作
2.1.1使用@Test
测试向数据库中插入用户信息的模块
2.1.2使用@Test
测试查询用户信息的模块
2.2添加@BeforeAll
注解
@BeforeAll
public static void setup_data(){
System.out.println("this is beforeall set up");
}
2.3@AfterAll
注解
@AfterAll
public static void tear_down_date(){
System.out.println("this is test end");
}
2.4@BeforeEach
注解
@BeforeEach
public void set_up(){
System.out.println("this is before_each set up");
}
2.5@AfterEach
注解
@AfterEach
public void tear_down_each(){
System.out.println("this is a after_each");
}
2.6添加 @DisplayName
`
2.7@Disabled
禁用