1、导入依赖
给当前项目的pom.xml增加单元测试依赖包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
2、新建Test
1、src下新建和main
目录平级的test
目录

2、
test
目录下新建MainTest
文件
3、
MainTest
写入
@RunWith(SpringRunner.class)
@SpringBootTest(classes = QuestionApplication.class)
public class MainTest {
@Test
public void output() {
System.out.println("Hello World");
}
}
-
QuestionApplication
为当前项目的application
文件
3、IDEA IDE配置

4、运行

网友评论