1. 通过IDEA开发工具,通过spring initialzr 创建SpringBoot工程,选择lombok
2. pom.xml 中添加 Junit 包依赖
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
// 注意事项:springboot对junit包依赖有版本限制,最好选择4.12 以上的
3. 创建测试类,添加:
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
4. 创建测试函数:
@Test
public void test1(){
System.out.print("hello world");
}
5. @Test左侧即可进行测试用例测试