对比
以前使用junit4
现在,springboot 2.4 自动使用junit5
没学springboot
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(“classpath*:spring/applicationContext-*.xml”)
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath*:spring/applicationContext-*.xml")
class Demo02junitApplicationTests {
//查询所有的Person
@Autowired
private IPersonService service;
@Test
void contextLoads() {
service.savePerson();
}
}
springboot 2.4 自动使用junit5
@SpringBootTest
@SpringBootTest
class Demo02junitApplicationTests {
//查询所有的Person
@Autowired
private IPersonService service;
@Test
void contextLoads() {
service.savePerson();
}
}
博客对比了以前使用JUnit4和现在Spring Boot 2.4自动使用JUnit5的情况。未使用Spring Boot时需特定配置,而Spring Boot 2.4可自动使用JUnit5,给出了两者不同的代码示例。
3387

被折叠的 条评论
为什么被折叠?



