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

}
相关推荐
噔噔噔噔@8 小时前
第一章、基础理论——第一节、软件测试概述
python·单元测试·压力测试
回眸&啤酒鸭10 小时前
【回眸】Contata单元测试(一)——小白使用篇
单元测试
程序员小远19 小时前
软件测试之单元测试详解
自动化测试·软件测试·python·测试工具·职场和发展·单元测试·测试用例
国家不保护废物1 天前
Vitest 学习与实践总结:在 React + TypeScript 项目中快速上手单元测试
单元测试·测试
zhengfei6111 天前
CVE-2025-49844 深度分析
junit
醇氧1 天前
JUnit 5的 Assertions
junit
测试19981 天前
单元测试、系统测试、集成测试
自动化测试·软件测试·python·测试工具·职场和发展·单元测试·集成测试
杀死那个蝈坦1 天前
OpenResty
junit·openresty
零基础的修炼1 天前
测试开发---测试分类
单元测试·测试用例·集成测试·压力测试·ab测试·模块测试
云半S一2 天前
春招准备之测试场景面试篇
单元测试