Spring boot 集成单元测试

1.引入依赖

复制代码
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

2.

3.编写测试类

复制代码
package com.enterprise;


import com.enterprise.entities.Company;
import com.enterprise.feignclient.IFeignCompanyService;
import com.enterprise.policy.service.PublishPolicyService;
import org.apache.commons.lang.StringUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@SpringBootTest
@RunWith(SpringRunner.class)
public class SpringBootTest01 {
    @Autowired
    private PublishPolicyService publishPolicyService;
    @Autowired
    private IFeignCompanyService companyService;
    @Test
    public void findOne() throws Exception {
        Map<String,String> rmap=new HashMap<>();
        rmap.put("companySize","SMALL_ENTERPRISE");
        rmap.put("companyPeriod","MEDIUM_PERIOD");
        rmap.put("companyAttribute","INDIVIDUAL_BUSINESS");

        List<Company> list =companyService.screenCompanyByPolicy(rmap);

        System.out.println(list);
    }
}
相关推荐
Elias不吃糖18 小时前
Java Lambda 表达式
java·开发语言·学习
情缘晓梦.18 小时前
C语言指针进阶
java·开发语言·算法
开五档的蒙奇18 小时前
【单元测试】Junit5 + Mockito
单元测试
南知意-20 小时前
IDEA 2025.3 版本安装指南(完整图文教程)
java·intellij-idea·开发工具·idea安装
码农水水20 小时前
蚂蚁Java面试被问:混沌工程在分布式系统中的应用
java·linux·开发语言·面试·职场和发展·php
海边的Kurisu20 小时前
苍穹外卖日记 | Day4 套餐模块
java·苍穹外卖
毕设源码-邱学长21 小时前
【开题答辩全过程】以 走失儿童寻找平台为例,包含答辩的问题和答案
java
他们叫我技术总监21 小时前
Python 列表、集合、字典核心区别
android·java·python
江沉晚呤时21 小时前
从零实现 C# 插件系统:轻松扩展应用功能
java·开发语言·microsoft·c#
梁下轻语的秋缘1 天前
ESP32-WROOM-32E存储全解析:RAM/Flash/SD卡读写与速度对比
java·后端·spring