springBoot_freemark配置

Spring Boot test

1、添加依赖

<!-- 引入 spring-boot-starter-test 集成单元测试-->

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-test</artifactId>

<version>1.5.6.RELEASE</version>

</dependency>

 

2、编写单元测试类 

package com.springboot.junit;

 

import java.util.List;

 

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.boot.test.context.SpringBootTest;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

 

import com.springboot.Application;

import com.springboot.domain.User;

import com.springboot.mapper.UserMapper;

 

@RunWith(SpringJUnit4ClassRunner.class)

@SpringBootTest(classes={Application.class})

public class UserTest {

@Autowired

private UserMapper userMapper;

 

@Test

public void testMapper() {

List<User> list = userMapper.findUserList();

System.out.println(list);

}

 

 

}

 

3、执行测试

 

posted @ 2019-02-20 11:43  zhangqi0828  阅读(276)  评论(0编辑  收藏  举报