pom引用

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.yyit</groupId>
<artifactId>demo</artifactId>
<version>1.0.0-SNAPSHOT</version> <name>demo</name> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/>
</parent> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.30</version>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

Application.java

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication
public class Application { public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

测试代码

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
public class AppTest { @Autowired
private BookRepository bookRepository; @Test
public void testgetPidList4MdmCrop() { Book book = bookRepository.findByName("abc"); System.out.println(book.toString()); } }

SpringBoot 单元测试junit test的更多相关文章

  1. Springboot单元测试Junit深度实践

    Springboot单元测试Junit深度实践 前言 单元测试的好处估计大家也都知道了,但是大家可以发现在国内IT公司中真正推行单测的很少很少,一些大厂大部分也只是在核心产品推广单测来保障质量,今天这 ...

  2. Springboot的日志管理&Springboot整合Junit测试&Springboot中AOP的使用

    ==============Springboot的日志管理============= springboot无需引入日志的包,springboot默认已经依赖了slf4j.logback.log4j等日 ...

  3. springmvc,springboot单元测试配置

    1. springmvc单元测试配置 <dependency> <groupId>junit</groupId> <artifactId>junit&l ...

  4. Spring注解AOP及单元测试junit(6)

    2019-03-10/20:19:56 演示:将xml配置方式改为注解方式 静态以及动态代理推荐博客:https://blog.csdn.net/javazejian/article/details/ ...

  5. Java单元测试(Junit+Mock+代码覆盖率)---------转

    Java单元测试(Junit+Mock+代码覆盖率) 原文见此处 单元测试是编写测试代码,用来检测特定的.明确的.细颗粒的功能.单元测试并不一定保证程序功能是正确的,更不保证整体业务是准备的. 单元测 ...

  6. Java学习——单元测试JUnit

    Java学习——单元测试JUnit 摘要:本文主要介绍了什么是单元测试以及怎么进行单元测试. 部分内容来自以下博客: https://www.cnblogs.com/wxisme/p/4779193. ...

  7. SpringBoot整合junit

    SpringBoot整合junit 主要分为4步 添加依赖 创建测试类 在测试类上添加注解 在测试类注入测试对象 1:导入依赖包 <dependency> <groupId>o ...

  8. SpringBoot与单元测试JUnit的结合

    有些人认为,写单元测试就是在浪费时间 ,写完代码,依然还是能够进行测试的.但是,还是建议写单元测试的,可以让你的条理更加清晰,而且当某个功能出现问题时,可能通过单元测试很容易的定位和解决问题.本文主要 ...

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

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

随机推荐

  1. create-react-app踩坑记

    前言 哇,不的不说这个react 这个脚手架create-react-app脚确实有很多问题,哈哈,下面来看看吧有哪些坑: 引用sass或者less 记得16年还是几年是不支持sass,和less的, ...

  2. python tkinter菜单

    python3中,Tkinter编写菜单界面案例 from tkinter import * top=Tk() top.wm_title("菜单") top.geometry(&q ...

  3. ftp CentOS7安装

    1.安装ftp服务yum install vsftpd 2.修改ftp配置文件(/etc/vsftpd/vsftpd.conf)ascii_upload_enable=YESascii_downloa ...

  4. js 中使用typeof

    >typeof(null) <"object" 对null执行typeof预算,结果返回字符串'object',也就是说,可以将null认为是一个特殊的对象值,含义是“ ...

  5. clojure的语法糖

    语法糖很多, 就是奔这个“懒” 来用clj的. 但是,在常见的书里(<Clojure编程><Clojure编程乐趣2>)都对很多基本语法,用法都介绍不全, 不细.看书看得很累. ...

  6. HDU3398—String-(组合数)

    Problem Description Recently, lxhgww received a task : to generate strings contain '0's and '1's onl ...

  7. 安装浏览器的vue插件

    安装浏览器的vue插件步骤: 1.在浏览器中打开 https://github.com/vuejs/vue-devtools Clone or download  vue-devtools. 2.解压 ...

  8. Xdebug bad Zend API Version Number

    I am having trouble upgrading xdebug for MAMP. I was running version 2.2.0 and there was a known iss ...

  9. eclipse.ini中加入-vm

    1. 在eclipse.ini中添加两行     -vm     C:\Program Files\Java\jdk1.6.0_02\bin\javaw.exe     注意: 要写在两行,写在一行不 ...

  10. 第五周总结 & 实验报告(三)

    第五周总结 一.继承       1.类的继承格式 class 父类{} class 子类 extends 父类{} 2.扩展类的功能 class 父类{ 父类属性: .......... ..... ...