1. 首先要下载配套的spring-boot-starter-test包,注意版本要对应。

compile("org.springframework.boot:spring-boot-starter-web:2.0.2.RELEASE")

// Use JUnit test framework
testImplementation 'junit:junit:4.12'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.0.2.RELEASE'

2. 示例

@RunWith(SpringRunner.class)
@SpringBootTest(classes = Springboot启动函数.class)
public class NumberServiceT {
@Autowired
NumberService ns; @Test
public void getNumberList() {
// NumberService ns = new NumberService();
ns.getUseableNumber();
} }

Springboot使用junit的更多相关文章

  1. Springboot的日志管理&Springboot整合Junit测试&Springboot中AOP的使用

    ==============Springboot的日志管理============= springboot无需引入日志的包,springboot默认已经依赖了slf4j.logback.log4j等日 ...

  2. SpringBoot整合junit

    SpringBoot整合junit 主要分为4步 添加依赖 创建测试类 在测试类上添加注解 在测试类注入测试对象 1:导入依赖包 <dependency> <groupId>o ...

  3. Springboot单元测试Junit深度实践

    Springboot单元测试Junit深度实践 前言 单元测试的好处估计大家也都知道了,但是大家可以发现在国内IT公司中真正推行单测的很少很少,一些大厂大部分也只是在核心产品推广单测来保障质量,今天这 ...

  4. springboot集成junit测试与javamail测试遇到的问题

    1.springboot如何集成junit测试? 导入junit的jar包 使用下面注解: @RunWith()关于这个的解释看下这两篇文章: http://www.imooc.com/qadetai ...

  5. SpringBoot学习16:springboot整合junit单元测试

    1.创建maven项目,修改pom.xml文件 <!--springboot项目依赖的父项目--> <parent> <groupId>org.springfram ...

  6. SpringBoot使用Junit测试 防止事物自动回滚

           问题:我在测试类中的save方法测试成功通过,但数据库没有插入数据 测试方法如下: @Test @Transactional // @Rollback(false) public voi ...

  7. Springboot整合Junit单元测试

    1.在pom.xml中添加junit环境的依赖 <dependency> <groupId>org.springframework.boot</groupId> & ...

  8. SpringBoot集成Junit

    1.在pom.xml下添加Junit依赖: <!--添加junit环境的jar包--> <dependency> <groupId>org.springframew ...

  9. SpringBoot 单元测试junit test

    pom引用 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http: ...

随机推荐

  1. Python小任务 - 如何编写指定时间执行的Python小程序

    我们在平时的工作中经常会遇到这样的需求,需要再某个时间点执行一段程序逻辑. 那么,在python中我们是怎么做的呢? 下面看代码: waitDesignatedTimeToRun.py import ...

  2. Excel常用快捷键大全

    一.关于处理工作表的快捷键总结 1.插入新工作表 Shift+F11或Alt+Shift+F1 2.移动到工作簿中的下一张工作表 Ctrl+PageDown 3.移动到工作簿中的上一张工作表 Ctrl ...

  3. MAC快捷方式记录

    刚刚转到MAC,很多功能发现不能用,总结一下: 刷新页面:command+r 命令行,到行首:control+a 命令行,到行尾:control+e vim,到行尾:shift+$ vim,到行首:s ...

  4. JEECG中的validform验证ajaxurl的使用方法

    validform验证是一种非常方便的,实用的验证方式 对于需要验证后台数据的,validform是一个非常明智的选择 validform的ajaxurl属性能够完美的实现:当输入完成某一输入框,就会 ...

  5. scala 基础语法

    文章内容全部来自:http://twitter.github.io/scala_school/zh_cn/index.html 表达式 scala> 1 + 1 res0: Int = 2 值 ...

  6. hadoop multipleoutputs

    http://grepalex.com/2013/05/20/multipleoutputs-part1/ http://grepalex.com/2013/07/16/multipleoutputs ...

  7. bash shell 获取当前正在执行脚本的绝对路径

    https://my.oschina.net/leejun2005/blog/150662 http://blog.csdn.net/10km/article/details/51906821 如题, ...

  8. Struts2学习笔记一:工作流程与核心文件

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6807539.html  1:客户端发出请求到web服务器 2:请求经过一系列filter,最终到达Struts ...

  9. 关于gitblit在Windows中无法Start的问题

    前期配置/data/defaults.properties文件,请自行百度 首先:找到该目录下的该文件 右键打开,找到SET ARCH=xx,将xx替换成x86 将该处的默认修改成配置环境变量的jvm ...

  10. Leetcode 240 Search a 2D Matrix II (二分法和分治法解决有序二维数组查找)

    1.问题描写叙述 写一个高效的算法.从一个m×n的整数矩阵中查找出给定的值,矩阵具有例如以下特点: 每一行从左到右递增. 每一列从上到下递增. 2. 方法与思路 2.1 二分查找法 依据矩阵的特征非常 ...