摘要:
https://github.com/powermock/powermock/wiki/MockitoUsage#a-full-example-for-mocking-stubbing--verifying-static-method 阅读全文
摘要:
要测试的类:IndexController.java 代码: @Mock private TemplateWrapper templateWrapper = spy(new TemplateWrapper()); @InjectMocks private IndexController contro 阅读全文
摘要:
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 阅读全文
摘要:
错误原因:通过定位发现是找不到TestRule这个类,检查项目引用的Junit版本为4.7,发现TestRule是在Junit版本4.10后添加的新特性 解决方法:把junit版本由4.7改成4.10 阅读全文
摘要:
verify(advertismentService).queryAdvitismentInfForApp(baseBOs, false); 阅读全文
摘要:
错误原因:mock的时候,不能mock重载的方法 解决方法:直接mock它的父类的方法 org.mockito.exceptions.misusing.CannotStubVoidMethodWithReturnValue: 'flush' is a *void method* and it *ca 阅读全文
摘要:
@RunWith(PowerMockRunner.class)@PrepareForTest(Helper.class)//1.添加要初始化的类,就是构造函数所在的类public class HelperTest { @Mock private Something mockSomething; @I 阅读全文
摘要:
//调用void方法 doNothing().when(templateWrapper).process();// doCallRealMethod().when(templateWrapper).process(); 阅读全文
摘要:
错误原因:invoke方法的时候,应该是类的实例对象,而不是类本身 解决方法:把 PowerMockito.doReturn(index_expect).when(IndexController.class, "processPage", pageCode, request, response, m 阅读全文
摘要:
在类开始的时候: @Rule public ExpectedException expectedEx = ExpectedException.none(); 在方法中执行下面代码: expectedEx.expect(BaseException.class); expectedEx.expectMe 阅读全文