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);
    }
}
相关推荐
爱喝一杯白开水12 分钟前
Java 定时任务完全指南
java
毕设源码-郭学长17 分钟前
【开题答辩全过程】以 高校自动排课系统的设计与实现为例,包含答辩的问题和答案
java
彭于晏Yan33 分钟前
MQTT消息服务
spring boot·后端·中间件
indexsunny1 小时前
互联网大厂Java面试实战:从Spring Boot到微服务架构的深度解析
java·spring boot·spring cloud·kafka·prometheus·security·microservices
java1234_小锋1 小时前
分享一套优质的SpringBoot+Vue咖啡商城系统
vue.js·spring boot·咖啡商城
ChoSeitaku1 小时前
NO.2|proto3语法|消息类型|通讯录|文件读取|enum类型
java·服务器·前端
庞轩px1 小时前
MinorGC的完整流程与复制算法深度解析
java·jvm·算法·性能优化
zhouping@1 小时前
JAVA学习笔记day06
java·笔记·学习
毕设源码-郭学长2 小时前
【开题答辩全过程】以 某某协会管理与展示平台为例,包含答辩的问题和答案
java
多云的夏天2 小时前
docker容器部署-windows-ubuntu
java·docker·容器