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

}
相关推荐
兰.lan1 天前
【黑马ai测试】黑马头条登录功能测试-发布功能测试-其他功能模块设计
软件测试·人工智能·笔记·python·功能测试·ai·单元测试
淼淼7631 天前
Qt单元测试
单元测试
Parasoft中国2 天前
单元测试告别人工!PARASOFT步入AI智能体时代!
单元测试
还是大剑师兰特2 天前
Vitest单元测试教程
单元测试
DJ斯特拉4 天前
Redis使用lua脚本
junit·单元测试·lua
2301_771717214 天前
idea中springboot中使用junit测试报错的解决方案
spring boot·junit·intellij-idea
念越4 天前
蓝桥杯单元测试模拟1期模拟题答案及代码解析
蓝桥杯·单元测试·测试
AIminminHu5 天前
OpenGL渲染与几何内核那点事-项目实践理论补充(三-1-(2):当你的CAD代码变得“又大又乱”:从手动编译到CMake,从随性编码到单元测试))
c++·单元测试·cmake·cad·cad开发
Java成神之路-5 天前
Spring 整合 MyBatis 全流程详解(附 Junit 单元测试实战)(Spring系列6)
spring·junit·mybatis