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. 在userMapper.xml文件中模糊查询的常用的3种方法

    在userMapper.xml文件中新建映射sql的标签 <!-- ******************** 模糊查询的常用的3种方式:********************* --> ...

  2. 一般程序中的session

    在WebHandler中无法访问session: IRequiresSessionState必须实现这个接口(不包含任何方法的标记接口), 需要导入using System.Web.SessionSt ...

  3. js时间国际化

    d = new Date(); localTime = d.getTime();localOffset = d.getTimezoneOffset() * 60000; utc = localTime ...

  4. SpringBoot 注解

    @RestController和@RequestMapping注解 我们的Example类上使用的第一个注解是 @RestController .这被称为一个构造型(stereotype)注解.它为阅 ...

  5. Windbg程序调试系列4-Live Debugging

    上篇博文中给大家分享了使用Windbg分析线程阻塞问题: Windbg程序调试系列3-线程阻塞问题 本篇中我们继续,跟大家分享附加进程实时调试-Live Debugging. 先说一下使用Windbg ...

  6. SQL中sysname数据类型的含义(转)

    sysname SQL Server 实例包括用户定义的名为 sysname 的数据类型.sysname 用于表列.变量以及用于存储对象名的存储过程参数.sysname 的精确定义与标识符规则相关:因 ...

  7. liunx驱动----按键中断

    liunx 中断 先设置异常入口 异常向量 void __init trap_init(void) 构造了异常向量 vector_irq+offset       按下按键: cpu自动进入异常模式 ...

  8. animate.css 动画的使用

    $('#animatedClose').removeClass().addClass('fadeInDownBig animated').one('webkitAnimationEnd mozAnim ...

  9. vue获取路由地址栏url里面的指定参数

    this.$route.query.gid     //gid是获取指定参数的名字

  10. Type Conversion

    文章著作权归作者所有.转载请联系作者,并在文中注明出处,给出原文链接. 本文原更新于作者的github博客,这里给出链接. 什么是转换 转换是接受一个类型的值并使用它作为另一个类型的等价值的过程.转换 ...