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);
    }
}
相关推荐
Skilce33 分钟前
ZrLog 高可用部署
运维·服务器·数据库·阿里云·maven
indexsunny3 小时前
互联网大厂Java求职面试实战:微服务与Spring生态全攻略
java·数据库·spring boot·安全·微服务·面试·消息队列
沪漂阿龙3 小时前
别再让数据库“吃”脏数据了!一文讲透MySQL约束,从入门到精通
数据库·mysql
毕业设计-小慧4 小时前
计算机毕业设计springboot游戏数据管理系统 基于SpringBoot的电竞赛事数据管理平台 基于SpringBoot的在线游戏运营数据分析系统
spring boot·游戏·课程设计
yuweiade5 小时前
springboot和springframework版本依赖关系
java·spring boot·后端
ywf12155 小时前
springboot设置多环境配置文件
java·spring boot·后端
2401_873544925 小时前
使用Python进行PDF文件的处理与操作
jvm·数据库·python
小马爱打代码5 小时前
SpringBoot + 消息生产链路追踪 + 耗时分析:从创建到发送,全链路性能可视化
java·spring boot·后端
虾..5 小时前
多路复用 --- select系统调用
服务器·数据库·sql
杨云龙UP5 小时前
mysqldump逻辑备份文件恢复总结:全库恢复、单库恢复,一篇讲明白
linux·运维·服务器·数据库·mysql·adb