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

}
相关推荐
__XYZ7 小时前
RedisTemplate 实现分布式锁
java·spring boot·redis·分布式·junit
lifewange10 小时前
幂等机制
功能测试·单元测试
=>>漫反射=>>1 天前
单元测试 vs Main方法调试:何时使用哪种方式?
java·spring boot·单元测试
子正2 天前
Pytest单元测试一例:u16采样值格式转换的错误
单元测试·pytest
另寻沧海2 天前
测试中的 AAA 模式与 Given–When–Then 模式详解
c++·单元测试·测试覆盖率
寒月霜华2 天前
java-高级技术(单元测试、反射)
java·开发语言·单元测试·反射
阿杰真不会敲代码3 天前
junit单元测试
junit·单元测试
程序员二黑4 天前
接口测试全流程实战:从工具到架构的深度解析
单元测试·测试·ab测试
步行cgn4 天前
JUnit 单元测试详细使用指南
junit·sqlserver·单元测试
Knight_AL4 天前
Java 单元测试全攻略:JUnit 生命周期、覆盖率提升、自动化框架与 Mock 技术
java·junit·单元测试