JUnit 5 单元测试框架

依赖安装

复制代码
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.13.2</version>
    <scope>test</scope>
</dependency>

所有支持的注解都在包 org.junit.jupiter.api 下。

基本使用:

java 复制代码
import org.junit.Assert;

import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.util.List;

@SpringBootTest
public class SampleTest {

    @Resource
    private UserMapper userMapper;

    @Test
    public void testSelect() {
        System.out.println(("----- selectAll method test ------"));
        List<User> userList = userMapper.selectList(null);
        Assert.assertEquals(5, userList.size());
        userList.forEach(System.out::println);
    }

}
相关推荐
晓晓hh4 小时前
JavaWeb学习——JUnit和日志
学习·junit·单元测试
测试员周周5 小时前
【AI测试系统】第1篇:LangGraph 实战:用 State Graph 搭建 AI测试流水线(4 步编排 + RAG 增强 + 完整代码)
linux·windows·python·功能测试·microsoft·单元测试·多轮对话
qq_452396239 小时前
第十三篇:《UI自动化测试框架设计:整合TestNG/JUnit + Allure报告》
ui·junit
aLTttY1 天前
Spring Boot + Redis 实现接口防抖与限流实战指南
spring boot·redis·junit
以为你知道啊1 天前
mini-job极简分布式延迟任务队列 — 基于 Redis,支持 Cron 周期任务、异步协程和多执行器
redis·分布式·junit
汽车仪器仪表相关领域1 天前
Kvaser Memorator Light HS v2:单通道 CAN FD 便携记录仪,即插即用的故障诊断利器
运维·服务器·数据库·人工智能·功能测试·单元测试
QH139292318802 天前
Rohde & Schwarz FSWX3044 FSWX3026信号与频谱分析仪
网络·功能测试·单元测试·集成测试·模块测试
胡利光2 天前
Harness Engineering 05|Safety & HITL Harness:边界、接管与回滚
junit
川石课堂软件测试2 天前
AI如何赋能软件测试行业的发展
人工智能·python·功能测试·网络协议·单元测试·测试用例·prometheus