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

}
相关推荐
什么都想学的阿超19 小时前
【Redis系列 03】掌握Redis编程艺术:事务、管道与Lua脚本完全指南
redis·junit·lua
AI+程序员在路上2 天前
单元测试与QTestLib框架使用
开发语言·c++·单元测试
RainbowJie13 天前
Spring Boot 使用 SLF4J 实现控制台输出与分类日志文件管理
spring boot·后端·单元测试
gb42152874 天前
springboot项目下面的单元测试注入的RedisConnectionFactory类redisConnectionFactory值为什么为空呢?
spring boot·后端·单元测试
大熊猫侯佩5 天前
用接地气的例子趣谈 WWDC 24 全新的 Swift Testing 入门(二)
单元测试·swift·apple
还是鼠鼠5 天前
单元测试-断言&常见注解
java·开发语言·后端·单元测试·maven
爱瑞瑞6 天前
Junit5测试类编写笔记
junit
孟陬6 天前
Bun test 常见问题
react.js·单元测试·bun
大熊猫侯佩6 天前
用接地气的例子趣谈 WWDC 24 全新的 Swift Testing 入门(一)
单元测试·swift·wwdc