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

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.测试结果

相关推荐
七夜zippoe14 分钟前
Java性能调优工具篇:JMH基准测试与Profiler(JProfiler/Async-Profiler)使用指南
java·开发语言·jprofiler·jmh·async-profiler
從南走到北19 分钟前
JAVA国际版二手车交易二手车市场系统源码支持Android+IOS+H5+APP
android·java·ios
Kuo-Teng27 分钟前
LeetCode 19: Remove Nth Node From End of List
java·数据结构·算法·leetcode·链表·职场和发展·list
北i29 分钟前
TiDB 关联子查询去关联优化实战案例与原理深度解析
java·数据库·sql·tidb
Kuo-Teng31 分钟前
LeetCode 21: Merge Two Sorted Lists
java·算法·leetcode·链表·职场和发展
我命由我1234536 分钟前
Java 开发 - 粘包处理器 - 基于消息头 + 消息体(魔数验证、长度验证)
java·网络·后端·网络协议·java-ee·intellij-idea·intellij idea
2301_8003997242 分钟前
stm32 printf重定向到USART
java·stm32·算法
bagadesu1 小时前
15.<Spring Boot 日志>
java·后端
laplace01231 小时前
Maven
java·maven
wdfk_prog1 小时前
Xshell终端连接Ubuntu/Debian无颜色的解决方案
java·ubuntu·debian