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

}
相关推荐
程序员三藏21 小时前
软件测试:白盒测试详解
自动化测试·软件测试·python·测试工具·职场和发展·单元测试·测试用例
sg_knight1 天前
使用 Claude Code 写单元测试的实战方法
单元测试·log4j·ai编程
汽车仪器仪表相关领域1 天前
动态间隙精准诊断:NHJX-13 型底盘间隙仪机动车底盘安全检测全方案
大数据·人工智能·机器学习·单元测试·压力测试·可用性测试
希望永不加班1 天前
SpringBoot 接口测试:Postman 与 JUnit 5 实战
java·spring boot·后端·junit·postman
難釋懷1 天前
OpenResty基于ID负载均衡
junit·负载均衡·openresty
難釋懷2 天前
OpenResty-CJSON工具类
junit·openresty
難釋懷2 天前
OpenResty封装http工具
http·junit·openresty
Greg_Zhong3 天前
小程序中单元测试对比表单测试,及单元测试、表单测试、组件测试的底层实现原理
小程序·单元测试
難釋懷4 天前
OpenResty监听请求
junit·openresty