在pom.xml添加依赖
1 <dependency> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-test</artifactId> 4 <scope>test</scope> 5 </dependency>
添加注解和测试方法
1 @RunWith(SpringJUnit4ClassRunner.class) // 告诉测试类使用的测试工具 2 @SpringBootTest(classes = MySpringBootApplication.class) // 指定启动器 3 public class MySpringBootTest { 4 5 @Autowired 6 private UserMapper userMapper; 7 8 /** 9 * 请写入测试方法 10 */ 11 @Test 12 public void test (){ 13 System.out.println("测试"); 14 List<User> users = userMapper.queryUserList(); 15 for (User user:users 16 ) { 17 System.out.println(user); 18 19 } 20 } 21 }
标签:Java,SpringBoot,System,添加,测试,test,class From: https://www.cnblogs.com/luyj00436/p/16706462.html