一、引入 Junit 依赖包:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
二、编写测试用例代码:
@RunWith(value = SpringRunner.class)
@SpringBootTest
public class UnitTest {
@Autowired
private VhclFeignClient vhclFeignClient;
@Test
public void testOne(){
CommonResult<Vhcl> vchlInfoById = vhclFeignClient.getVchlInfoById(1);
System.out.println("vchlInfoById = " + vchlInfoById);
}
}
说明:
1、@RunWith(value = SpringRunner.class) 注解代表系统会把 javabean 加载到 spring 容器中,否则无法注入接口对象
网友评论