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

}
相关推荐
AmyLin_20012 天前
AI 如何做出数学发现【5】- AI 数学证明怎样做单元测试:从“看起来顺”到可否证工作流
人工智能·单元测试·openai·数学推理·符号计算·ai推理·反例生成
是小艺吗。2 天前
第三方机构出具的软件功能测试报告的作用与流程说明,中承信安专业讲解
功能测试·单元测试·软件测试报告·软件功能测试·软件测评
测试老哥3 天前
软件测试:单元测试详解
自动化测试·软件测试·python·测试工具·职场和发展·单元测试·测试用例
回眸&啤酒鸭4 天前
【回眸】搞钱灵感——智能体 汽车软件单元测试与集成测试
单元测试·汽车·集成测试
小龙飞刀6 天前
Chrome插件自动化测试:单元测试、集成测试
chrome·单元测试·集成测试
LayZhangStrive6 天前
claude code使用命令技巧(四)(开发沉淀的提示词模板)
ai·单元测试·prompt·ai编程·提示词·claude code
難釋懷7 天前
Nginx外置缓存-redis2-nginx-module
nginx·缓存·junit
栈溢出的浪漫9 天前
Python单元测试框架覆盖率-Coverage
python·单元测试·工具·覆盖率·coverage
名字还没想好☜10 天前
Go 表驱动测试实战:用 t.Run 子测试组织可维护的单元测试
golang·单元测试·log4j·go·testing