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 天前
Java - Junit框架
java·junit·log4j
还是鼠鼠1 天前
JMeter 教程:编写 GET 请求脚本访问百度首页
功能测试·jmeter·单元测试
我是Superman丶2 天前
【Lua】java 调用redis执行 lua脚本
java·开发语言·junit
LuXi_foryou3 天前
错误: 程序包org.junit不存在 import org.junit.Test;
junit·android studio
伊成4 天前
一文详解Spring Boot如何配置日志
java·spring boot·单元测试
文人sec4 天前
接口自动化测试设计思路--设计实战
python·https·单元测试·自动化·pytest
Aric_Jones4 天前
lua入门语法,包含安装,注释,变量,循环等
java·开发语言·git·elasticsearch·junit·lua
神探阿航5 天前
HNUST软件测试B考前最终复习
软件测试·单元测试·hnust·期中考试
csdn_freak_dd6 天前
查看单元测试覆盖率
java·单元测试
sheepfagdng8 天前
软件测试——用例篇(2)
功能测试·单元测试·测试用例·安全性测试