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

}
相关推荐
汽车仪器仪表相关领域14 小时前
液力传动精准标定 + 智能换挡控制,动力总成测试新高度:GZCVL T‑IV 变矩器变速箱测试系统实战全解
功能测试·单元测试·汽车·压力测试·可用性测试·安全性测试
prince0518 小时前
基于redis实现扣减库存的具体实现
数据库·redis·junit
程序员小远20 小时前
单元测试知识详解
自动化测试·软件测试·python·测试工具·职场和发展·单元测试·测试用例
Predestination王瀞潞20 小时前
2.3 依赖管理Maven工具->dependency详解:JUnit 3.8.1 vs 4.12
数据库·junit
Warren9821 小时前
Spring Boot + JUnit5 + Allure 测试报告完整指南
java·spring boot·后端·面试·单元测试·集成测试·模块测试
上海合宙LuatOS1 天前
LuatOS核心库API——【 string】字符串操作
运维·服务器·物联网·junit·硬件工程·信息与通信·嵌入式实时数据库
steel80881 天前
Spring Boot 整合 log4j2 日志配置教程
spring boot·单元测试·log4j
川石课堂软件测试2 天前
接口测试需要注意的一些BUG
网络·数据库·python·单元测试·bug·压力测试·tornado
Arya_aa2 天前
Mysql数据库-管理和存储数据库(开源管理系统)与JDBC操作数据库步骤,JUnit以及如何将压缩包中exe程序添加上桌面图标
数据库·mysql·junit·开源
CodeCraft Studio3 天前
Parasoft C/C++嵌入式软件测试解决方案:安全、可靠且符合标准
开发语言·c++·安全·单元测试·代码规范·parasoft·嵌入式软件测试