IDEA中的JUNIT测试
安装插件
Ctrl+Alt+s→Plugins→junitgenerator v2.0

Alt+insert 选中JUnit test 中JUnit4
package test.com.demo.controller; import com.baomidou.mybatisplus.plugins.Page;
import com.demo.DemoApplication;
import com.demo.entity.User;
import com.demo.error.ErrorCode;
import com.demo.exceptionHander.BusinessException;
import com.demo.service.IUserService;
import org.junit.After;
import org.junit.Before;
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.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.util.List;
/**
* UserController Tester.
* springboot 需要添加的注解@SpringBootTest(classes = DemoApplication.class)
* springmvc 添加 @ContextConfiguration(locations="classpath:spring.xml")
* @since <pre>五月 13, 2019</pre>
* @version 1.0
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = DemoApplication.class)
public class UserControllerTest { @Autowired
private IUserService userService; private long times; @Before
public void before() throws Exception {
times= System.currentTimeMillis();
System.out.println("测试开始"+times);
} @After
public void after() throws Exception {
System.out.println("测试结束"+(System.currentTimeMillis()-times));
} /**
*
* Method: getPage(@ApiParam(required = true,name = "current",value = "用户数据第几页")Integer current, @ApiParam(required = true,name = "size",value = "用户数据展示个数")Integer size)
*
*/
@Test
public void testGetPage() throws Exception { } }
IDEA中的JUNIT测试的更多相关文章
- Android中的Junit测试
在开发中Junit测试可以很方便的帮助开者尽可能早的发现并处理问题,而且使用也非常简单,只需要导入Junit测试相关的jar包并创建测试类,就可以对业务功能进行测试,而不用为了测试在代码中添加输出语句 ...
- Javaspring+mybit+maven中实现Junit测试类
在一个Javaspring+mybit+maven框架中,增加Junit测试类. 在测试类中遇到的一些问题,利用spring 框架时,里面已经有保密security+JWT设定的场合,在你的secur ...
- 在命令行中运行JUnit测试
可以在Eclipse之外运行JUnit测试,使用org.junit.runner.JUnitCore类. 这个类提供了runClasses()方法,它允许运行一个或多个测试类.runClasses() ...
- java中使用junit测试
最初写代码只要功能走通就不管了,然后如果出了什么问题再去修改,这是因为没做测试的工作.测试其实很简单. 1.准备 当前使用idea编写代码,用maven构建工程,使用maven的test功能来进行批量 ...
- 【IDEA】单元测试:项目中引入JUnit测试框架+Mock简单了解
一.Junit 使用和说明: 参考:单元测试第三弹--使用JUnit进行单元测试-HollisChuang's Blog http://www.hollischuang.com/archives/17 ...
- 在SpringBoot中使用Junit测试
一:加入依赖 <dependency> <groupId>junit</groupId> <artifactId>junit</artifactI ...
- Spring Boot中进行Junit测试
Spring Boot新版本默认使用Junit5,pom依赖为: <dependency> <groupId>org.springframework.boot</grou ...
- idea中使用junit测试时使用Scanner类无法正常测试
解决办法是:在main函数中测试方可有效. public static void main(String[] args){ Scanner sc = new Scanner(System.in);// ...
- IDEA导入Junit jar包,在JavaSE的Module中使用Junit测试
写代码时偶尔想试一下自己的小想法,于是在IDEA中建了一个JavaEE项目.JavaEE项目中只能在main方法中运行代码块,不如单元测试的@Test灵活. 于是在网上找到了Junit的jar包:Do ...
随机推荐
- 2019-8-31-git-上传当前分支
title author date CreateTime categories git 上传当前分支 lindexi 2019-08-31 16:55:59 +0800 2018-05-08 09:2 ...
- 基于Nutch+Hadoop+Hbase+ElasticSearch的网络爬虫及搜索引擎
基于Nutch+Hadoop+Hbase+ElasticSearch的网络爬虫及搜索引擎 网络爬虫架构在Nutch+Hadoop之上,是一个典型的分布式离线批量处理架构,有非常优异的吞吐量和抓取性能并 ...
- 学习Java第六周
1.内存结构 Java程序在运行时,需要在内存中的分配空间为提高运算效率,空间进行了不同区域的划分,因为每一片区域都有特定的处理数据方式和内存管理方式. 栈内存 ·用于存储局部变量,当数据使用完,所占 ...
- Java中的Redis 哨兵高可用性
让我们探索Redis Sentinel,看看如何在Java上运行它,一起来看看,最近get了很多新知识,分享给大家参考学习.需要详细的java架构思维导图路线也可以评论获取! 什么是Redis哨兵? ...
- 五分钟学Java:可变参数究竟是怎么一回事?
在逛 programcreek 的时候,我发现了一些专注基础但不容忽视的主题.比如说:Java 的可变参数究竟是怎么一回事?像这类灵魂拷问的主题,非常值得深入地研究一下. 我以前很不重视基础,觉得不就 ...
- Linux中编写shell脚本的小例子
1.创建一个test.sh的文件 touch test.sh 2.编辑这个文件 vi test.sh 3.进入到编辑页面后将编辑页面先切换成编辑模式(按Esc键就可以切换) 4.切换到编辑模式后开始向 ...
- 使用SparkSql进行表的分析与统计
# 背景 我们的数据挖掘平台对数据统计有比较迫切的需求,而Spark本身对数据统计已经做了一些工作,希望梳理一下Spark已经支持的数据统计功能,后期再进行扩展. # 准备数据 在参考文献6中下载 ...
- JS-数组常用方法整理
想了解数组有哪些原生方法,控制台输出,如图: length:数组的实例属性,返回或设置一个数组中的元素个数. toString():可以把数组转换成字符串,并返回结果. toLocaleString( ...
- 【题解】BZOJ1034 [ZJOI2008]泡泡堂BNB(贪心)
[题解]BZOJ1034 [ZJOI2008]泡泡堂BNB(贪心) 考虑直接模拟田忌赛马... 我的最小比你的大,直接上 我的最大比你的大,直接上 otherwise,我小换你大 考虑最劣,由于每次比 ...
- HDU3652 B-number 题解 数位DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3652 题目大意: 求区间 \([1, n]\) 范围内包含连续的数位"13"并且能 ...