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);
    }
}
相关推荐
张柏慈10 分钟前
Java性能优化:实战技巧与案例解析
java
天“码”行空15 分钟前
简化Lambda——方法引用
java·开发语言
带刺的坐椅1 小时前
MCP 进化:让静态 Tool 进化为具备“上下文感知”的远程 Skills
java·ai·llm·agent·solon·mcp·tool-call·skills
java1234_小锋1 小时前
Java线程之间是如何通信的?
java·开发语言
张张努力变强1 小时前
C++ Date日期类的设计与实现全解析
java·开发语言·c++·算法
while(1){yan}2 小时前
Spring事务
java·数据库·spring boot·后端·java-ee·mybatis
毕设源码-赖学姐2 小时前
【开题答辩全过程】以 高校社团管理平台为例,包含答辩的问题和答案
java
余瑜鱼鱼鱼3 小时前
线程和进程的区别和联系
java·开发语言·jvm
小唐同学爱学习3 小时前
如何解决海量数据存储
java·数据库·spring boot·mysql
962464i3 小时前
SBE(simple-binary-encoding)-Demo
java