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

}
相关推荐
feathered-feathered6 小时前
测试实战【用例设计】自己写的项目+功能测试(1)
java·服务器·后端·功能测试·jmeter·单元测试·压力测试
测试渣8 小时前
持续集成中的自动化测试框架优化实战指南
python·ci/cd·单元测试·自动化·pytest
minh_coo11 小时前
Spring单元测试之反射利器:ReflectionTestUtils
java·后端·spring·单元测试·intellij-idea
金銀銅鐵1 天前
浅解 JUnit 4 第九篇:JUnitCore (下)
junit·单元测试
钟智强1 天前
CVE-2025-49844高危预警:Redis Lua脚本引擎UAF漏洞深度剖析与POC实战
数据库·redis·web安全·junit·lua
A懿轩A1 天前
【Maven 构建工具】Maven + JUnit5 单元测试实战:测试级别、注解、断言与 Maven test 阶段
java·单元测试·maven
金銀銅鐵2 天前
浅解 JUnit 4 第八篇:JUnitCore (上)
junit·单元测试
派大星-?2 天前
自动化测试五模块一框架(上)
开发语言·python·测试工具·单元测试·可用性测试
少云清3 天前
【UI自动化测试】2_PO模式 _单元测试框架(重点)
ui·单元测试·po模式
清水白石0083 天前
测试金字塔实战:单元测试、集成测试与E2E测试的边界与平衡
python·单元测试·log4j·集成测试