一、引入 test、Junit 依赖包:
<!-- 单元测试依赖 <scope>test</scope> 只在测试时使用 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
二、编写测试用例代码:
@Slf4j
@RunWith(value = SpringRunner.class)
@SpringBootTest
@Profile(value = {"dev", "sit"})
public class UnitTestOne {
@Resource
private UserInfoService userInfoService;
@Test
public void getUserInfoById() {
UserInfo userInfo = userInfoService.getByI