工具
IntelliJ IDEA
前提條件
1、pom.xml文件引入Junit依賴
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
idea配置
1、打開idea,點擊File -> Settings -> plungins
2、輸入框中輸入junit,點擊紅色框的按鈕并進行下一步操作
3、點擊Apply,之后重啟idea
4、打開需要建立測試類的文件,光標移入該類,點擊Navigate -> Test
5、點擊 Create New Test
6、創建Test類,勾選中需要測試的方法
7、完成