pom.xml 引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
java 示例
import com.terry.HelloService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
/**
* 单元测试
*
* @author terry
* @version 1.0
* @date 2022/8/16 21:51
*/
@SpringBootTest
public class TestJunit {
@Test
public void test(){
System.out.println(" hello junit");
}
@Autowired
private HelloService helloService;
@Test
public void testService(){
helloService.hello();
}
}
使用junit