JUnit 4 + Spring Boot 测试依赖

1.pom导入依赖

复制代码
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

2.在src同目录下创建test/java

3.编写测试类

复制代码
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;



@RunWith(SpringRunner.class)
@SpringBootTest
public class Test1 {

    @Test
    public void testSqlOutput() {
        System.out.println(111);
    }
}
相关推荐
大筒木老辈子2 小时前
MySQL笔记---表的约束
数据库·笔记·mysql
涤生大数据2 小时前
从MR迁移到Spark3:数据倾斜与膨胀问题的实战优化
数据库·数据仓库·spark·mapreduce·大数据开发·数据倾斜·spark3
加洛斯3 小时前
MySQL 函数篇(3):常用的时间日期函数
数据库·mysql
合作小小程序员小小店3 小时前
web开发,在线%车辆管理%系统,基于Idea,html,css,vue,java,springboot,mysql
java·spring boot·vscode·html5·web app
安审若无3 小时前
解决 sqlplus / as sysdba 登录缓慢问题
运维·服务器·数据库
龙茶清欢3 小时前
在 Spring Cloud Gateway 中实现跨域(CORS)的两种主要方式
java·spring boot·spring cloud·微服务·gateway
小哈里4 小时前
【后端开发】golang部分中间件介绍(任务调度/服务治理/数据库/缓存/服务通信/流量治理)
数据库·缓存·中间件·golang·后端开发
m0_619731195 小时前
linux配置数据库
linux·运维·数据库
重启的码农5 小时前
kv数据库-leveldb (16) 跨平台封装-环境 (Env)
数据库