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
}
}
}