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);
    }
}
相关推荐
计算机毕设定制辅导-无忧学长4 小时前
《基于Spring Boot的减脂轻食购物网站》
java·vue.js·spring boot·后端·减脂轻食购物网站
青山木4 小时前
Hot 100 --- 下一个排列
java·数据结构·算法·leetcode
Thinker QAQ4 小时前
并发编程(六):Atomic 的实现——从 Runtime 到 CPU
java·go·cas·并发编程·atomic·cpython
沐欣工作室_lvyiyi4 小时前
基于SpringBoot的博物馆预约系统设计与实现(论文+源码)
java·spring boot·后端·计算机毕业设计
程序员清风6 小时前
Java 智能体开发:从对话接口到任务执行
java·人工智能·python
一 乐6 小时前
博客管理系统|基于springboot + vue博客管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·毕设
QuZhengRong6 小时前
【Spring】后端接收的请求参数多了一个逗号的处理办法
java·后端·spring
ZealSinger6 小时前
Go1.25容器感知GOMAXPROCS避限流
java·开发语言
cxoptics6 小时前
LBO 会不会潮解?存储、镀膜、日常使用注意事项?
java