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

}
相关推荐
kyriewen1 天前
前端测试:别为了100%覆盖率而写测试,那是自欺欺人
前端·javascript·单元测试
小短腿的代码世界1 天前
Qt券商接口封装深度解析:统一API设计与多源适配
开发语言·qt·单元测试
Dylan的码园1 天前
Maven基础架构与整体认识
java·junit·maven
小短腿的代码世界2 天前
Qt WebEngine深度解析:Chromium多进程架构与Qt信号槽的双向融合
qt·搜索引擎·单元测试
上海合宙LuatOS2 天前
32位固件和64位固件使用场景
物联网·junit·luatos
晓晓hh3 天前
JavaWeb学习——JUnit和日志
学习·junit·单元测试
测试员周周3 天前
【AI测试系统】第1篇:LangGraph 实战:用 State Graph 搭建 AI测试流水线(4 步编排 + RAG 增强 + 完整代码)
linux·windows·python·功能测试·microsoft·单元测试·多轮对话
qq_452396233 天前
第十三篇:《UI自动化测试框架设计:整合TestNG/JUnit + Allure报告》
ui·junit
aLTttY4 天前
Spring Boot + Redis 实现接口防抖与限流实战指南
spring boot·redis·junit