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);
    }
}
相关推荐
千里镜宵烛6 分钟前
Lua 面向对象编程完全指南:从元表到私密性,解锁灵活封装技巧
junit·单元测试·lua
w_t_y_y8 分钟前
主流模型调用
java
昔我往昔11 分钟前
Gateway整合knife4报错404 (Not Found)
java
三口吃掉你12 分钟前
微服务之网关(Spring Cloud Gateway)
java·网关·微服务·gateway
Kent_J_Truman23 分钟前
JDK Maven Tomcat Spring在VSCode中的部分配置细节(自用)
java·tomcat·maven
邂逅星河浪漫27 分钟前
【Java】异常详解+实例演示+知识总结
java·异常·exception
她说人狗殊途32 分钟前
面试题001
java
Han.miracle34 分钟前
Java的多线程——多线程(3)线程安全
java·开发语言·jvm·学习·安全·线程·多线程
大象席地抽烟35 分钟前
spring中使用rabbitmq(spring-boot-starter-amqp)
java
0小豆039 分钟前
【系列开篇】从零构建智能字幕校准系统:一个AI+微服务的完整实战之旅
spring boot·python·nlp·微服务架构·实战项目·spacy·ai算法