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);
    }

}
相关推荐
renke33641 天前
Flutter 2025 测试工程体系:从单元测试到混沌演练,构建高可靠、可验证、自动化的质量保障闭环
flutter·单元测试·自动化
卓码软件测评1 天前
软件测试:如何在Postman中配置和自动化OAuth 2.0与JWT认证?
测试工具·单元测试·自动化·测试用例·postman·可用性测试
要开心吖ZSH1 天前
Spring Boot + JUnit 5 + Mockito + JaCoCo 单元测试实战指南
java·spring boot·junit·单元测试
secondyoung1 天前
Pandoc转换Word文档:使用Lua过滤器统一调整Pandoc文档中的图片和表格格式
经验分享·junit·word·lua·markdown·pandoc·mermaid
Knight_AL1 天前
Redis Lua 脚本核心语法详解:KEYS[1]、ARGV[1]、tonumber 是什么意思?
redis·junit·lua
汽车仪器仪表相关领域2 天前
GZCVL T-II 安全防坠器测试系统
功能测试·测试工具·安全·单元测试·压力测试·可用性测试
木风小助理2 天前
分布式系统统一限流:基于Redis与Lua的跨实例流量管控方案
junit
小明的小名叫小明2 天前
Solidity入门(14)-Hardhat 3 单元测试基础与技巧
单元测试·区块链·solidity·hardhat
音浪豆豆_Rachel2 天前
Flutter跨平台通信的实战演练:复杂数据结构与单元测试在鸿蒙生态中的完美实现
数据结构·flutter·单元测试·harmonyos
白露与泡影2 天前
Java单元测试、集成测试,区别
java·单元测试·集成测试