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

}
相关推荐
Best-Wishes11 小时前
科来网络分析系统(技术交流版)使用说明书
开发语言·junit·php
2302_8057710715 小时前
Day24:DDT+EXCEL数据驱动
功能测试·单元测试·自动化·测试用例·需求分析·web自动化
贾宝玉的玉宝贾21 小时前
FreeSWITCH 简单图形化界面 70 - 监听/密语的lua脚本
开发语言·junit·lua·voip·freeswitch·sip·ippbx
孟陬1 天前
不用盲调性能参数 Vitest 5.0 新推出 `vitest doctor` 一键诊断测试慢卡点,自动给出最优提速配置
性能优化·单元测试·vite
企业数字化笔记2 天前
多租户系统从哪里开始设计?租户身份、数据隔离、权限与套餐的整体方案
java·spring boot·后端·junit
网络毒刘5 天前
端到端:用 Cursor Agent 完成「小功能 + 单测 + PR 描述」并附人工验收清单
单元测试·agent·ai编程·cursor·工具实践
mont evergreen5 天前
RTMP 连接单元测试之旅
单元测试·音视频·源码解读
我就是不信6 天前
CuTest:轻量级 C 语言单元测试框架实战指南
c语言·单元测试·log4j
众链网络6 天前
大客流票务系统怎么防超卖:库存并发、候补队列与幂等设计的工程取舍
junit·架构
深念Y9 天前
rime-雾凇拼音-配置记录
linux·junit·软件·拼音·kde