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

}
相关推荐
金銀銅鐵6 小时前
浅解 Junit 4 第五篇:IgnoredBuilder 和 RunnerBuilder
junit·单元测试
桂花很香,旭很美10 小时前
[7天实战入门Go语言后端] Day 6:测试与 Docker 部署——单元测试与多阶段构建
docker·golang·单元测试
观音山保我别报错2 天前
抽奖项目-接口自动化测试
功能测试·测试工具·单元测试
高山上有一只小老虎3 天前
SpringBoot项目单元测试
spring boot·后端·单元测试
金銀銅鐵3 天前
浅解 Junit 4 第四篇:类上的 @Ignore 注解
java·junit·单元测试
金銀銅鐵4 天前
浅解 Junit 4 第二篇: Runner 和 ParentRunner
java·junit·单元测试
流云细水4 天前
Spec实战:需求开发与单元测试如何一一对应?
单元测试
金銀銅鐵4 天前
浅解 Junit 4 第三篇:Suite
junit·单元测试
HashFlag5 天前
单元测试-gomonkey
单元测试·go·gomonkey
HashFlag5 天前
单元测试-httptest
单元测试·go·httptest