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 ...
随机推荐
- 对int类型的数据,如何让获取长度
下面为大家写一个列子 int a = 124;<br> Integer a1 = a;//转换为包装类Integer<br> System.out.println(a1.t ...
- C# 方法扩展
using System.Collections.Generic; namespace Extra_Function { public static class Function { public s ...
- 常见的四种文本自动分词详解及IK Analyze的代码实现
以下解释来源于网络-百度百科 1.word分词器 word分词 [1] 是一个Java实现的分布式的中文分词组件,提供了多种基于词典的分词算法,并利用ngram模型来消除歧义.能准确识别英文.数字, ...
- 自定义Win10右键“发送到”菜单
打开Win10文件资源管理器窗口(打开“这台电脑”或任一文件夹即可),然后在资源管理器窗口的地址栏中输入 shell:sendto ,回车或点击地址栏右侧的“转到”箭头即可打开“SendTo(发送到) ...
- PostgreSQL 9.5.x的架构图及外存图
- 实现一个自定义的ArrayList类,实现将原List中的每个数据都乘以10
1.首先自定义一个Operate接口,如下所示: public interface Operate { public Integer caozuo(Integer i); } 2.实现自定义的Arra ...
- WCF基础二
1:地址 . WCf 的每一个服务都有一个唯一地址,地址包括传输协议和服务位置. HTTP:采用http\https协议进行传输,默认端口为80. TCP:采用ne.tcp协议进行传输,默认端口为80 ...
- Vue系列之 => html-webpack-plugin的两个基本作用
安装 npm i html-webpack-plugin -D webpack.config.js const path = require('path'); //启用热更新的第二步,导入webpac ...
- Vue-Router路由Vue-CLI脚手架和模块化开发 之 vue-router路由
vue-router路由:Vue.js官网推出的路由管理器,方便的构建单页应用: 单页应用(SPA)只有一个web页面的应用,用户与应用交互时,动态更新该页面的内容:简单来说,根据不同的url与数据, ...
- nginx配置访问频率
nginx可以通过limit_conn_zone和limit_req_zone两个组件来限制客户端访问服务端的目录和文件的频率和次数,能够抵挡住部分cc.ddos攻击. 限制访问频率: http{ . ...