若依框架-添加测试类-最新

1、在【ruoyi-admin】的pom.xml下添加依赖

XML 复制代码
        <!-- 单元测试-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <scope>test</scope>
        </dependency>

2、update一下maven(确认单元测试已经添加进来)

3、添加在src下创建test模块(与main同级)

4.创建测试类

XML 复制代码
import com.aide.CMSApplication;
import com.aide.mqtt.parse.domain.DataFile;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest(classes = CMSApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class UnitTest {
	@Autowired
	private DataFile dataFile;

	@Test
	public void test1() {
		System.out.println(dataFile.toString());
	}
}

5.测试结果

相关推荐
学长毕设16 小时前
基于SpringBoot的实验室资产管理系统
java·spring boot·后端
zzu123zsw18 小时前
从臃肿的模板调用到声明式契约:深入 UniHttp 动态代理与多渠道生命周期扩展
java·spring boot·microsoft·unihttp
源码集结号18 小时前
云诊所门诊系统源码,基于SpringBoot+Vue.js架构,支持多租户设计与Docker容器化部署
java·spring boot·源码·医院信息系统·门诊系统·诊所系统
论文复现现场19 小时前
WRF、FEA 能用 L40S 加速吗?求解器检查、断点恢复与长期运行
java·数据库·算法·wrf·有限元分析·gpu计算·断点续算
啃瓜子的松鼠19 小时前
泛微OAe9-后端二开异步调用
java
秋天的怀念_David20 小时前
第二十一夜 · 数字黑洞与西西弗斯的惩罚
java·程序人生·算法
外收内放20 小时前
Python基础语法练习题(73)
java·前端·python
Wang's Blog20 小时前
Java 项目实战: 交友项目 - 环信后台发送消息测试
java·交友
用户37215742613521 小时前
Java 操作 Word 脚注和尾注:添加、读取与删除
java
小嘉丶学长21 小时前
Day14 · 字典与集合
java·开发语言·网络·python·学习·1024程序员节