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

}
相关推荐
观音山保我别报错2 小时前
抽奖项目-接口自动化测试
功能测试·测试工具·单元测试
高山上有一只小老虎15 小时前
SpringBoot项目单元测试
spring boot·后端·单元测试
金銀銅鐵1 天前
浅解 Junit 4 第四篇:类上的 @Ignore 注解
java·junit·单元测试
金銀銅鐵2 天前
浅解 Junit 4 第二篇: Runner 和 ParentRunner
java·junit·单元测试
流云细水2 天前
Spec实战:需求开发与单元测试如何一一对应?
单元测试
金銀銅鐵2 天前
浅解 Junit 4 第三篇:Suite
junit·单元测试
HashFlag3 天前
单元测试-gomonkey
单元测试·go·gomonkey
HashFlag3 天前
单元测试-httptest
单元测试·go·httptest
HashFlag3 天前
单元测试-go-sqlmock
golang·单元测试·sqlmock
万能的小裴同学3 天前
饥荒Mod
java·开发语言·junit