美文网首页
Springboot测试类

Springboot测试类

作者: 庙人 | 来源:发表于2018-12-21 15:39 被阅读0次

Springboot测试类使用Junit框架

pom引入jar包支持
<!--  test 启动器  -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
添加test类
package com.duck.test;

import com.duck.DuckAdminApplication;
import com.duck.dao.SysUserMapper;
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.SpringRunner;

import java.util.HashMap;

@RunWith(SpringRunner.class)
@SpringBootTest(classes={DuckAdminApplication.class})// 指定启动类
public class DuckTest {

    @Autowired
    SysUserMapper sysUserMapper;

    @Test
    public void testQueryUser(){
        System.out.println(sysUserMapper.querySysUser(new HashMap()));
    }
}
运行即可查看结果
image.png

相关文章

网友评论

      本文标题:Springboot测试类

      本文链接:https://www.haomeiwen.com/subject/tkzmkqtx.html