安装插件

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测试的更多相关文章

  1. Android中的Junit测试

    在开发中Junit测试可以很方便的帮助开者尽可能早的发现并处理问题,而且使用也非常简单,只需要导入Junit测试相关的jar包并创建测试类,就可以对业务功能进行测试,而不用为了测试在代码中添加输出语句 ...

  2. Javaspring+mybit+maven中实现Junit测试类

    在一个Javaspring+mybit+maven框架中,增加Junit测试类. 在测试类中遇到的一些问题,利用spring 框架时,里面已经有保密security+JWT设定的场合,在你的secur ...

  3. 在命令行中运行JUnit测试

    可以在Eclipse之外运行JUnit测试,使用org.junit.runner.JUnitCore类. 这个类提供了runClasses()方法,它允许运行一个或多个测试类.runClasses() ...

  4. java中使用junit测试

    最初写代码只要功能走通就不管了,然后如果出了什么问题再去修改,这是因为没做测试的工作.测试其实很简单. 1.准备 当前使用idea编写代码,用maven构建工程,使用maven的test功能来进行批量 ...

  5. 【IDEA】单元测试:项目中引入JUnit测试框架+Mock简单了解

    一.Junit 使用和说明: 参考:单元测试第三弹--使用JUnit进行单元测试-HollisChuang's Blog http://www.hollischuang.com/archives/17 ...

  6. 在SpringBoot中使用Junit测试

    一:加入依赖 <dependency> <groupId>junit</groupId> <artifactId>junit</artifactI ...

  7. Spring Boot中进行Junit测试

    Spring Boot新版本默认使用Junit5,pom依赖为: <dependency> <groupId>org.springframework.boot</grou ...

  8. idea中使用junit测试时使用Scanner类无法正常测试

    解决办法是:在main函数中测试方可有效. public static void main(String[] args){ Scanner sc = new Scanner(System.in);// ...

  9. IDEA导入Junit jar包,在JavaSE的Module中使用Junit测试

    写代码时偶尔想试一下自己的小想法,于是在IDEA中建了一个JavaEE项目.JavaEE项目中只能在main方法中运行代码块,不如单元测试的@Test灵活. 于是在网上找到了Junit的jar包:Do ...

随机推荐

  1. keep-alive及路由渲染

    切换路由的时候,每次切换的时候得重新渲染一遍,这样的话会影响到性能的.此时用<keep-alive>包裹着app里的<router-view>,进行缓存. 如果一个页面涉及到了 ...

  2. 洛谷——P1540机器翻译(队列操作)

    #include<bits/stdc++.h> using namespace std; int main(){ queue<int> num;//存放的内存 ]; int m ...

  3. Hbase概念原理扫盲

    一.Hbase简介 1.什么是Hbase Hbase的原型是google的BigTable论文,收到了该论文思想的启发,目前作为hadoop的子项目来开发维护,用于支持结构化的数据存储. Hbase是 ...

  4. You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.

    异常 You are using the runtime-only build of Vue where the template compiler is not available. Either ...

  5. Java 学习笔记(4)——java 常见类

    上次提前说了java中的面向对象,主要是为了使用这些常见类做打算,毕竟Java中一切都是对象,要使用一些系统提供的功能必须得通过类对象调用方法.其实Java相比于C来说强大的另一个原因是Java中提供 ...

  6. ffmpeg 转码并截图的命令分析

    一.转码并截图的命令分析: 1.转码并截图,将码率转换为900Kffmpeg -i E:\\1.MOV -i E:\\123.jpg -filter_complex overlay=W-w  -b:v ...

  7. .NETCore3.1中的Json互操作最全解读-收藏级

    前言 本文比较长,我建议大家先点赞.收藏后慢慢阅读,点赞再看,形成习惯! 我很高兴,.NETCore终于来到了3.1LTS版本,并且将支持3年,我们也准备让部分业务迁移到3.1上面,不过很快我们就遇到 ...

  8. Spring Boot 整合 slf4j+log4j2 实现日志管理

    背景 Java 中比较常用的日志框架: log4j(Log for Java):Apache 的一个开源项目,七种日志级别:OFF.FATAL.ERROR.WARN.INFO.DEBUG.TRACE ...

  9. tomcat日志传参乱码问题

    问题:      在centos系统下,tomcat8.0.36控制台日志打印会出现中文乱码. 解决方案:      在catalina.sh里加上 JAVA_OPTS="-Dfile.en ...

  10. js的class基础

    title: js的class基础 date: 2020-01-04 13:34:44 tags: --- 基本写法 let log = console.log; class people { con ...