码迷,mamicode.com
首页 > 其他好文 > 详细

mock打桩测试

时间:2019-11-17 01:31:24      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:tco   version   artifact   order   parse   ring   request   url   代码   

pom依赖:

<!-- https://mvnrepository.com/artifact/org.jmockit/jmockit -->
<dependency>
    <groupId>org.jmockit</groupId>
    <artifactId>jmockit</artifactId>
    <version>1.48</version>
    <scope>test</scope>
</dependency>

测试代码:

@Test
    public void testRefundOrderQuery() {
        RefundOrderQueryFullRequest refundOrderQueryFullRequest = new RefundOrderQueryFullRequest();
        refundOrderQueryFullRequest.setRefundNo("10000001");
        
        new MockUp<UMPayOrderServiceImpl>() {
            @Mock
            public Map<String,Object> postAndParseData(String url,Map<String,Object> reqMap,Class<?> responseType){
                Map<String,Object> map = new HashMap<String,Object>();
                map.put("ret_code", "0000");
                return map;
            }
        };
        RefundOrderQueryFullResponse refundOrderQuery = umpayOrderServiceImpl.refundOrderQuery(refundOrderQueryFullRequest);
        assertEquals("0000",refundOrderQuery.getRetCode());
    }

 

mock打桩测试

标签:tco   version   artifact   order   parse   ring   request   url   代码   

原文地址:https://www.cnblogs.com/vianzhang/p/11874802.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!