安装插件

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. Eclipse文档注释导出doc

    选择要导出的项目,右键选择Export 直接next,在最后finish之前加上编码格式.要不然会出现乱码

  2. tensorflow在文本处理中的使用——CBOW词嵌入模型

    代码来源于:tensorflow机器学习实战指南(曾益强 译,2017年9月)——第七章:自然语言处理 代码地址:https://github.com/nfmcclure/tensorflow-coo ...

  3. Vue-route页面切换过渡动画

    重点:   1.判断路由前进还是后退 2.切换时动画如何实现 1.需要给各个页面定义层级,切换路由时判断进入哪个层级页面,如果进入层级高页面做前进动画,否则做后退动画在路由定义中添加meta自定义参数 ...

  4. activiti工作流引擎学习(二)

    1.连线 如果bpmn文件和java文件放在同一目录下,需要配置buildPath: 使用流程变量,设置连线需要的流程变量的名称,并设置流程变量的值,流程会按照指定的连线完成任务. 1.1一个活动中可 ...

  5. The Struts dispatcher cannot be found异常的解决方法

    系统错误:HTTP Status 500 异常信息:The Struts dispatcher cannot be found.  This is usually caused by using St ...

  6. Python3 安装pylint 及与PyCharm关联

    使用如下命令: pip3 install pylint 安装完后可以看到在你的python3的目录底下的Scripts目录下有pylint.exe了 然后就可以使用pylint 评估你的代码了,如: ...

  7. C# 字符串与二进制的相互转换

    /// <summary> /// 将字符串转成二进制 /// </summary> /// <param name="s"></para ...

  8. linux MySQL 5.7.20安装教程

    安装MySQL 5.7.20shell> cd /usr/localshell> groupadd mysqlshell> useradd -g mysql mysqlshell&g ...

  9. 1086 就不告诉你 (15分)C语言

    做作业的时候,邻座的小盆友问你:"五乘以七等于多少?"你应该不失礼貌地微笑着告诉他:"五十三."本题就要求你,对任何一对给定的正整数,倒着输出它们的乘积. 输入 ...

  10. Intellij Idea插件使用记录之Alibaba Java Coding Guidelines

    目录 Intellij Idea插件Alibaba Java Coding Guidelines 前言 使用 感谢 Intellij Idea插件Alibaba Java Coding Guideli ...