1.引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
2.文章来源:https://www.toymoban.com/news/detail-674329.html
3.编写测试类文章来源地址https://www.toymoban.com/news/detail-674329.html
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);
}
}
到了这里,关于Spring boot 集成单元测试的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!