上一页 1 ··· 47 48 49 50 51 52 53 54 55 ··· 81 下一页
摘要: https://github.com/powermock/powermock/wiki/MockitoUsage#a-full-example-for-mocking-stubbing--verifying-static-method 阅读全文
posted @ 2017-03-16 14:20 ppjj 阅读(449) 评论(0) 推荐(0) 编辑
摘要: 要测试的类:IndexController.java 代码: @Mock private TemplateWrapper templateWrapper = spy(new TemplateWrapper()); @InjectMocks private IndexController contro 阅读全文
posted @ 2017-03-14 14:55 ppjj 阅读(17487) 评论(0) 推荐(0) 编辑
摘要: 1.<#if isChanged==1>id="skin_${skins_index*skins?size+skin_index+1}"<#else>id="skin_${skin_index+1}"</#if> 2.<a <#if advitismentFlag == 1>readonly="re 阅读全文
posted @ 2017-03-09 20:31 ppjj 阅读(2259) 评论(0) 推荐(0) 编辑
摘要: 错误原因:通过定位发现是找不到TestRule这个类,检查项目引用的Junit版本为4.7,发现TestRule是在Junit版本4.10后添加的新特性 解决方法:把junit版本由4.7改成4.10 阅读全文
posted @ 2017-03-07 19:32 ppjj 阅读(1123) 评论(0) 推荐(0) 编辑
摘要: verify(advertismentService).queryAdvitismentInfForApp(baseBOs, false); 阅读全文
posted @ 2017-03-06 20:24 ppjj 阅读(448) 评论(0) 推荐(0) 编辑
摘要: 错误原因:mock的时候,不能mock重载的方法 解决方法:直接mock它的父类的方法 org.mockito.exceptions.misusing.CannotStubVoidMethodWithReturnValue: 'flush' is a *void method* and it *ca 阅读全文
posted @ 2017-03-03 14:58 ppjj 阅读(2967) 评论(0) 推荐(0) 编辑
摘要: @RunWith(PowerMockRunner.class)@PrepareForTest(Helper.class)//1.添加要初始化的类,就是构造函数所在的类public class HelperTest { @Mock private Something mockSomething; @I 阅读全文
posted @ 2017-03-03 11:38 ppjj 阅读(10078) 评论(0) 推荐(0) 编辑
摘要: //调用void方法 doNothing().when(templateWrapper).process();// doCallRealMethod().when(templateWrapper).process(); 阅读全文
posted @ 2017-03-02 15:14 ppjj 阅读(1123) 评论(0) 推荐(0) 编辑
摘要: 错误原因:invoke方法的时候,应该是类的实例对象,而不是类本身 解决方法:把 PowerMockito.doReturn(index_expect).when(IndexController.class, "processPage", pageCode, request, response, m 阅读全文
posted @ 2017-03-01 17:13 ppjj 阅读(5556) 评论(0) 推荐(0) 编辑
摘要: 在类开始的时候: @Rule public ExpectedException expectedEx = ExpectedException.none(); 在方法中执行下面代码: expectedEx.expect(BaseException.class); expectedEx.expectMe 阅读全文
posted @ 2017-03-01 16:30 ppjj 阅读(1030) 评论(0) 推荐(0) 编辑
上一页 1 ··· 47 48 49 50 51 52 53 54 55 ··· 81 下一页