1、pom.xml 添加jar
<!-- 测试类 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
2、创建测试类,注:Application.class 为启动类
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {Application.class})
public class MethodTests {
@Test
public void contextLoads() {
try {
} catch (Exception e) {
// TODO: handle exception
}
}
}