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

}
相关推荐
卓码软件测评3 天前
第三方软件测试测评机构【使用web_reg_save_param_ex函数:掌握LoadRunner关联的黄金法则 】
测试工具·ci/cd·性能优化·单元测试·测试用例
汽车仪器仪表相关领域3 天前
全程高温伴热,NOx瞬态精准捕捉:MEXA-1170HCLD加热型NOx测定装置项目实战全解
大数据·服务器·网络·人工智能·功能测试·单元测试·可用性测试
Apifox.3 天前
测试用例越堆越多?用 Apifox 测试套件让自动化回归更易维护
运维·前端·后端·测试工具·单元测试·自动化·测试用例
潇凝子潇3 天前
在 Maven 中跳过单元测试进行本地打包或排除某个项目进行打包
java·单元测试·maven
weixin_462446233 天前
在宝塔 Nginx 上安装与配置 lua-cjson 教程
nginx·junit·lua
凯子坚持 c3 天前
C++大模型SDK开发实录(二):DeepSeek模型接入、HTTP通信实现与GTest单元测试
c++·http·单元测试
大熊猫侯佩3 天前
Swift 6.2 列传(第十八篇·大结局):冯衡的“过目不忘”与语言的圆满
单元测试·macro·test·evaluate·swift testing·swift 6.2·大结局
不吃鱼的羊3 天前
单元测试基础
单元测试
oscar9994 天前
CI_CD 管道:是什么、为什么以及如何构建
ci/cd·单元测试·压力测试
卓码软件测评5 天前
软件信创测试和软件首版次认定机构【使用Postman的Pre-request Script动态处理数据】
测试工具·ci/cd·性能优化·单元测试·测试用例