在spring-boot-starter-test 2.5.5版本之前
测试方法是在测试类上面
添加@RunWith注解
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfigurantion(classes=AddressBookConfiguration.class)
public class Test(){
@Test
......
}
在spring-boot-starter-test 2.5.5版本之后舍弃掉了@RunWith
@SpringBootTest
class SpringbootnoeApplicationTests {
@Test
void contextLoads() {
}
}
@SpringBootTest 即可