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

}
相关推荐
路修远i24 分钟前
前端单元测试
前端·单元测试
曲莫终1 小时前
junit自定义ArgumentsSource以自定义ParameterizedTest参数加载方式
junit
测试人社区-千羽16 小时前
48小时攻克测试岗——闪电面试极速备战手册
人工智能·python·opencv·面试·职场和发展·单元测试·压力测试
力江20 小时前
FastAPI 最佳架构实践,从混乱到优雅的进化之路
python·缓存·架构·单元测试·fastapi·分页·企业
Jomurphys1 天前
测试 - 单元测试(JUnit)
android·junit·单元测试
Elastic 中国社区官方博客1 天前
Elasticsearch:使用判断列表评估搜索查询相关性
大数据·数据库·elasticsearch·搜索引擎·单元测试·全文检索
卓码软件测评2 天前
第三方数据库测试:【utPLSQL用于Oracle和tSQLt用于SQL Server数据库单元测试框架入门】
数据库·oracle·sqlserver·单元测试·mssql
babywew12 天前
单相逆变器Matlab仿真:TCM模式和CCM模式
单元测试
一过菜只因2 天前
使用Junit测试
服务器·数据库·junit
张较瘦_2 天前
Springboot3 | JUnit 5 使用详解
spring boot·junit