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

  1. 基于Springboot+Junit+Mockito做单元测试

    前言 前面的两篇文章讨论过< 为什么要写单元测试,何时写,写多细 >和<单元测试规范>,这篇文章介绍如何使用Springboot+Junit+Mockito做单元测试,案例选取 ...

  2. springboot+junit测试

    文章目录 一.junit断言 二.测试模块 三.使用Mockito作为桩模块 四.使用mockMvc测试web层 五.批量测试和测试覆盖率 参考视频:用Spring Boot编写RESTful API ...

  3. SpringBoot Junit测试Controller

    原文链接:https://blog.csdn.net/xiaolyuh123/article/details/73281522 import java.util.List; import org.sp ...

  4. SpringBoot Junit Demo

    package com.yunen.camera.test; import org.junit.Before; import org.junit.Test; import org.junit.runn ...

  5. SpringBoot Junit Maven JaCoCo

    写一下最近写单体测试的一些笔记. SrpingBoot的测试用例: @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = ...

  6. springboot junit单元测试报错

    1.测试类中如下方框为主函数 2.application.yml注意如下2个地方 3.主函数

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

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

  8. SpringBoot: 16.整合junit单元测试(转)

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

  9. SpringBoot集成Junit

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

随机推荐

  1. linux 笔记 第一天

    打开终端:ctrl+alt+t 清屏:ctrl+l 在终端在退出锁定:ctrl+c 目录:又称为文件夹,是包含所有的文件 目录创建规则: 1.大小是256 2.不能包含特殊字符 3.见名知义 路径:是 ...

  2. cygwin 安装 apt-cyg

    apt-cyg apt-cyg is a Cygwin package manager. It includes a command-line installer for Cygwin which c ...

  3. es6 遍历总结

    1.for in / for of for in --> index是key值 var array = [1,2,3,4,5]; for(let index in array) { consol ...

  4. JavaFX-Stage

    1.Stage类继承自Window类,继承了Window类的show()方法,Stage的close()方法实际上是调用了继承自Window类的hide()方法.另外还有Window的setOpaci ...

  5. DIJKSTRA 临接表

    #include <iostream> #include <algorithm> #include <cmath> #include <cstdio> ...

  6. mysql:数据库备份方案

    1. 数据库备份方案     1)没备份,跑路~     2)全量备份+增量备份 如果不小心“删库”,可以这么恢复: a. 将最近一次全量备份的全库找到,拷贝回来(文件一般比较大),解压,应用: b. ...

  7. Linux基础命令---iostat显示设备状态

    iostat iostat指令用来显示cpu状态,系统IO设备的状态,以及相关磁盘和NFS使用状态.iostat命令通过观察设备相对于其平均传输速率的活动时间来监视系统输入/输出设备负载.iostat ...

  8. vue配置手机通过IP访问,Win10让局域网内其他电脑通过IP访问网站的方法

    vue配置手机通过IP访问config/index.js// Various Dev Server settings host: '0.0.0.0', // can be overwritten by ...

  9. redis(一主两从三哨兵模式搭建)记录

    转自:http://www.cnblogs.com/fly-piglet/p/9836314.html 目的: 让看看这篇文章的的人能够知道:软件架构.软件的安装.配置.基本运维的操作.高可用测试.也 ...

  10. TeamCity 创建jar构建步骤

    1 创建工程 2 配置工程代码来源信息 2.1 From a repository URL 表示从代码仓库创建工程. 2.1.1 parent project 指定父工程,默认是root projec ...