导包
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><scope>test</scope></dependency>
import cn.hutool.json.JSONUtil;import cn.hutool.log.Log;import cn.hutool.log.LogFactory;import com.github.pagehelper.PageHelper;import com.hn.Application;import com.hn.common.utils.sql.SqlUtil;import org.junit.runner.RunWith;import org.springframework.boot.test.context.SpringBootTest;import org.springframework.test.context.junit4.SpringRunner;import java.util.List;/*** web单元测试继承该类即可*/@RunWith(SpringRunner.class)@SpringBootTest(classes = Application.class)public abstract class TesterBase {public static final Integer userId = 1;private static final Log log = LogFactory.get("TesterBase");public void toJsonStr(Object o) {log.info("### " + JSONUtil.formatJsonStr(JSONUtil.toJsonStr(o)));}protected void startPage(String orderBy) {Integer pageNum = 1;Integer pageSize = 20;String orderByValue = SqlUtil.escapeOrderBySql(orderBy);PageHelper.startPage(pageNum, pageSize, orderByValue);}public void assertSize(List list) {assert list != null && list.size() > 0;}}

