一、导入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
二、创建测试类
1 package com.offcn.boot;
2
3 import com.offcn.HelloApplication;
4 import com.offcn.dao.MUserMapper;
5 import com.offcn.dao.UserDao;
6 import com.offcn.entity.User;
7 import com.offcn.pojo.MUser;
8 import org.junit.Test;
9 import org.junit.runner.RunWith;
10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.boot.test.context.SpringBootTest;
12 import org.springframework.test.context.junit4.SpringRunner;
13
14 import java.util.List;
15
16 @RunWith(SpringRunner.class)
17 @SpringBootTest(classes = HelloApplication.class)
18 public class TestApp {
19
20
21 @Autowired
22 MUserMapper mUserMapper;
23 @Test
24 public void test01(){
25
26 List<MUser> mUserList = mUserMapper.getMUserList();
27 for (MUser mUser:mUserList) {
28 System.out.println(mUser);
29 }
30 }
31 }