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

}
相关推荐
AI领路人.2 小时前
[特殊字符] 用 OpenClaw 实现一个 C++ 复刻版 QuantClaw
websocket·单元测试·discord·rest api·内存占用·c++17
神奇小梵1 天前
《javaweb基础》后端篇————maven补充(用maven单元测试,maven常见问题)
单元测试·maven
AmyLin_20015 天前
AI 如何做出数学发现【5】- AI 数学证明怎样做单元测试:从“看起来顺”到可否证工作流
人工智能·单元测试·openai·数学推理·符号计算·ai推理·反例生成
是小艺吗。6 天前
第三方机构出具的软件功能测试报告的作用与流程说明,中承信安专业讲解
功能测试·单元测试·软件测试报告·软件功能测试·软件测评
测试老哥7 天前
软件测试:单元测试详解
自动化测试·软件测试·python·测试工具·职场和发展·单元测试·测试用例
回眸&啤酒鸭7 天前
【回眸】搞钱灵感——智能体 汽车软件单元测试与集成测试
单元测试·汽车·集成测试
小龙飞刀9 天前
Chrome插件自动化测试:单元测试、集成测试
chrome·单元测试·集成测试
LayZhangStrive10 天前
claude code使用命令技巧(四)(开发沉淀的提示词模板)
ai·单元测试·prompt·ai编程·提示词·claude code
難釋懷10 天前
Nginx外置缓存-redis2-nginx-module
nginx·缓存·junit