我的:
(1)依赖
<properties>
<!--忽略单元测试,避免打包时报错-->
<skipTests>true</skipTests>
</properties>
<!--Spring boot 单元测试-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
(2) 测试
package com.test;
import com.test.service.CommonService;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class AdminApplicationTest {
@Autowired
CommonService commonService;
@Test
public void test(){
commonService.sendSmsVerifyCode("15626299333");
}
}