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

}
相关推荐
一个快乐的小测试1 天前
JUnit-自动化测试框架
java·junit·单元测试·自动化
laoliu19961 天前
GGE Lua 详细教程
开发语言·junit·lua
长路 ㅤ   2 天前
Java单元测试JUnit
junit·单元测试·springboot·注解·断言
chao_7892 天前
pytest 实战演练【pytest】
自动化测试·单元测试·自动化·pytest
你的人类朋友3 天前
【✈️速通】什么是SIT,什么是UAT?
后端·单元测试·测试
嵌入式-老费4 天前
LVGL应用和部署(用lua做测试)
单元测试
Hello.Reader4 天前
Redis性能基准测试
数据库·redis·junit
_GR4 天前
一篇博客学习Lua_安装使用+语法详解
开发语言·junit·lua
甜鲸鱼4 天前
在Maven多模块项目中进行跨模块的SpringBoot单元测试
spring boot·单元测试·maven
车载测试工程师5 天前
汽车功能安全-软件单元验证 (Software Unit Verification)【用例导出方法、输出物】8
网络·功能测试·安全·车载系统·单元测试·汽车