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. Yarn 组件的指挥部 – 调度器Scheduler

    linux基础 为hadoop集群的搭建扫清了障碍,也为内存的管理,文件系统的管理扫清了障碍 接着到Hadoop的阶段,首先做集群的安装,深入到使用这两个核心的组件,分布式文件系统HDFS,解决大量数 ...

  2. 依据ECMA规范,手写一个bind函数

    Function.prototype.bind 函数,参见ECMA规范地址 如题,这次来实现一个boundFunction函数,不挂载在Function.prototype上,而是一个单独声明的函数. ...

  3. windows 中的类似于sudo的命令(在cmd中以另一个用户的身份运行命令)

    linux中我们习惯用sudo命令来临时用另一个用户的身份执行命令. windows中,通常我们需要用管理员权限执行命令的时候通常是 右键->run as administrator. 用着键盘 ...

  4. 网络库压力测试:mongols VS evpp

    evpp是360出品的一个网络库,基于libevent,进行了许多改造,对c++11友好.据称比libevent性能要好. 到底有多好呢?360开发人员有自己的测试,信不信由你. evpp源码下有个h ...

  5. DDL、DML和DCL的区别与理解

    DML.DDL.DCL区别 . 总体解释: DML(data manipulation language): 它们是SELECT.UPDATE.INSERT.DELETE,就象它的名字一样,这4条命令 ...

  6. linux 网络设置

    centos7 ifcfg-ens33静态ip地址配置 vim /etc/sysconfig/network-scripts/ifcfg-ens33  TYPE=EthernetPROXY_METHO ...

  7. datagridview 查询数据库数据

    private void btnsearch_Click(object sender, EventArgs e) { if (txtSearch.Text != "") { thi ...

  8. Jenkins安装及基本配置(Linux版,使用web容器 tomcat 搭建)

    Jenkins是什么 Jenkins 是一个可扩展的持续集成引擎. 主要用于:      1 持续.自动地构建/测试软件项目.     2 监控一些定时执行的任务. Jenkins拥有的特性包括:   ...

  9. Node.js建立服务、路径处理与响应

    通过Node.js创建一个web服务器,要写的代码可能不是最少的,但是一定是最容易理解的. 用6行代码创建的web服务器 当在浏览器中访问http://127.0.0.1:1337会看到自定义的字样 ...

  10. shell 构建脚本基础

    bash -v test.sh 启用 verbose 调试模式 bash -n test.sh  启用语法检查调试模式 bash -x test.sh  遍历脚本执行过程 一.基础参数 1.shell ...