springboot junit
1 添加pom依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> 2
// 获取启动类,加载配置,确定装载 Spring 程序的装载方法,它回去寻找 主配置启动类
@SpringBootTest
// 让 JUnit 运行 Spring 的测试环境, 获得 Spring 环境的上下文的支持
@RunWith(SpringRunner.class)
public class AutoWorkflowDemoTest { @Autowired
private RepositoryService repositoryService; @Test
public void test(){
System.out.println(repositoryService);
} } 3 注意一点很重要,我就是在这块卡了阵子!!!!
测试类的包名一定要和启动类的包名路径一致,不然会报错! 路径要一致!
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test

springboot junit的更多相关文章
- 基于Springboot+Junit+Mockito做单元测试
前言 前面的两篇文章讨论过< 为什么要写单元测试,何时写,写多细 >和<单元测试规范>,这篇文章介绍如何使用Springboot+Junit+Mockito做单元测试,案例选取 ...
- springboot+junit测试
文章目录 一.junit断言 二.测试模块 三.使用Mockito作为桩模块 四.使用mockMvc测试web层 五.批量测试和测试覆盖率 参考视频:用Spring Boot编写RESTful API ...
- SpringBoot Junit测试Controller
原文链接:https://blog.csdn.net/xiaolyuh123/article/details/73281522 import java.util.List; import org.sp ...
- SpringBoot Junit Demo
package com.yunen.camera.test; import org.junit.Before; import org.junit.Test; import org.junit.runn ...
- SpringBoot Junit Maven JaCoCo
写一下最近写单体测试的一些笔记. SrpingBoot的测试用例: @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = ...
- springboot junit单元测试报错
1.测试类中如下方框为主函数 2.application.yml注意如下2个地方 3.主函数
- SpringBoot学习16:springboot整合junit单元测试
1.创建maven项目,修改pom.xml文件 <!--springboot项目依赖的父项目--> <parent> <groupId>org.springfram ...
- SpringBoot: 16.整合junit单元测试(转)
1.创建maven项目,修改pom.xml文件 <!--springboot项目依赖的父项目--> <parent> <groupId>org.springfram ...
- SpringBoot集成Junit
1.在pom.xml下添加Junit依赖: <!--添加junit环境的jar包--> <dependency> <groupId>org.springframew ...
随机推荐
- debian9升级安装到python3.6和pip3.6
安装步骤 1.添加testing源 vim /etc/apt/sources.list deb http://mirrors.163.com/debian/ testing main 2.更新源 ap ...
- 对于Java Bean的类型转换问题()使用 org.apache.commons.beanutils.ConvertUtils)
在进行与数据库的交互过程中,由数据库查询到的数据放在 map 中,由 map 到 JavaBean 的过程中可以使用 BeanUtils.populate(map,bean)来进行转换 这里要处理的问 ...
- Intellij IDEA 配置Tomcat远程调试
一.前言 在服务器端开发过程中,由于服务器环境差异导致运行结果不符合预期. 所以就需要到IDEA Debug 服务器代码.看起来貌似很高大上的事情. 今天就说说使用Intellij IDEA 配置的方 ...
- Junit4 之 Assert 静态方法介绍
Junit中的assert方法全部放在Assert类中,总结一下junit类中assert方法的分类. 1.assertTrue/False([String message,]boolean cond ...
- IDEA 创建Web项目
1,创建Project:依次点击File–new Project: 创建.png 2,选择Empty Project项目,点击Next: 下一步 3,输入项目名称,选择项目路径: Past ...
- Angular.js指令
ng-style <input type="button" value="set color" ng-click="myStyle={col ...
- tiny6410 启动参数
baudrate=115200 bootargs=noinitrd root=/dev/nfs nfsroot=192.168.1.116:/home/suxuandong/Documents/com ...
- 解决mysql连接报“Communications link failure”错误
<!--定义在从数据库获取新连接失败后重复尝试的次数.默认值: 30 :小于等于0表示无限次--> <property name="acquireRetryAttempts ...
- 清除Windows 10的文件夹浏览痕迹
windows 10有一个功能就是在快速访问时显示“最近访问的文件”,“常用文件”.如果是一台共用电脑,这个功能会经常暴露自己的“行踪”. 可以在“文件夹选项”-“隐私”中去掉勾选,并点击“清除”来清 ...
- /var/log各种日志
文章为装载 1)/var/log/secure:记录登录系统存取数据的文件;例如:pop3,ssh,telnet,ftp等都会记录在此. 2)/ar/log/btmp:记录登录这的信息记录,被编码过, ...