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

}
相关推荐
谷粒.12 小时前
让缺陷描述更有价值:测试报告编写规范的精髓
java·网络·python·单元测试·自动化·log4j
晚霞的不甘13 小时前
Flutter + OpenHarmony 自动化测试全攻略:从单元测试到多设备真机云测
flutter·单元测试
雨落秋垣13 小时前
优化 OpenResty 的性能
junit·openresty
川石课堂软件测试1 天前
自动化测试的基本概念及常用框架
数据库·python·功能测试·测试工具·单元测试·自动化·流程图
川石课堂软件测试1 天前
使用loadrunner调用mysql API进行性能测试
服务器·数据库·python·selenium·mysql·单元测试·自动化
旦莫1 天前
Pytest教程: Pytest ini配置文件深度剖析
python·单元测试·自动化·pytest
子春一1 天前
Flutter 测试体系全栈指南:从单元测试到 E2E,构建坚如磐石的高质量应用
flutter·单元测试
子春一1 天前
Flutter 测试金字塔:从单元测试到端到端验证的完整工程实践
flutter·单元测试
雨中散步撒哈拉1 天前
21、做中学 | 高一上期 |Golang单元测试
golang·单元测试·log4j
嗝屁小孩纸2 天前
利用OpenResty统计网站访问量
junit·openresty