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 天前
39_Java单元测试JUnit入门
java·junit·单元测试
骇客之技术12 天前
AutoLua:在安卓上写 Lua 脚本
android·junit·lua
果子耶耶12 天前
让大模型帮我写单元测试,5个模型的覆盖率和边界处理能力实测
chatgpt·单元测试
闪电悠米12 天前
黑马点评-Redis ZSet-实现关注 Feed 流
服务器·网络·数据库·redis·缓存·junit·lua
川石课堂软件测试13 天前
APP自动化测试|高级手势操作&toast操作
css·功能测试·测试工具·microsoft·fiddler·单元测试·harmonyos
Thecozzy15 天前
单元测试 vs 手工测试:以水印功能为例
单元测试
小小龙学IT15 天前
C++20 协程深度解析:从原理到高性能异步框架实战
junit·c++20
HLAIA光子16 天前
AI Coding框架,打好TDD和SDD这两拳
单元测试·ai编程·代码规范
IT策士16 天前
Redis 从入门到精通:事务与 Lua 脚本
redis·junit·lua