1. 添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
2. 在包路径test/java下创建一个java类
import com.tdd.Application;
import com.tdd.service.StuService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
public class StuTest {
@Autowired
StuService stuService;
@Test
public void getAll() {
stuService.selectAll();
}
}
3. 如下图:
本文暂时没有评论,来添加一个吧(●'◡'●)