text Mockito,PowerMock依赖项
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text Mockito,PowerMock依赖项相关的知识,希望对你有一定的参考价值。
testImplementation 'org.mockito:mockito-core:2.13.0'
testImplementation 'org.powermock:powermock-api-mockito2:1.7.3'
testImplementation 'org.powermock:powermock-module-junit4:1.7.3'
testImplementation 'org.powermock:powermock-core:1.7.3'
testImplementation 'org.powermock:powermock-module-junit4-rule:1.7.3'
@RunWith( PowerMockRunner.class )
@PrepareForTest({FirebaseCrash.class})
public class DateUtilsTest {
...
@Test
public void formatNewsApiDate_incorrectDate_outputsIncorrectDate() {
PowerMockito.mockStatic(FirebaseCrash.class);
String outputDate = DateUtils.formatNewsApiDate(incorrectInputDate1);
assertEquals(outputDate, incorrectInputDate1);
PowerMockito.verifyStatic(FirebaseCrash.class);
FirebaseCrash.report(ArgumentMatchers.isA(ParseException.class));
}
assertEquals(outputDate, incorrectInputDate1);
PowerMockito.verifyStatic(FirebaseCrash.class);
FirebaseCrash.report(ArgumentMatchers.isA(ParseException.class));
}
以上是关于text Mockito,PowerMock依赖项的主要内容,如果未能解决你的问题,请参考以下文章
Mockito和PowerMock用法
PowerMock使用指南
如何使用 mockito/powermock 模拟 Google 的地理编码 API 请求?
如何使用 Mockito/Powermock 模拟枚举单例类?
PowerMock、EasyMock 和 Mockito 框架有啥区别? [复制]
模拟系统类时的 Mockito + PowerMock LinkageError