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()));
}
}
网友评论