我想用powermock来模拟私有方法,但我的PowerMock在MockitoBusinessOperation MockitoBusinessOperation = PowerMock.createPartialMock(MockitoBusinessOperation.class, "inTestMethod");
中未被识别。我用行家和和的Mockito的powermock依赖在我的POM文件如何使用Mockito和TestNG模拟使用PowerMock的私人方法
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-mockito-release-full</artifactId>
<version>1.4.9</version>
<scope>test</scope>
</dependency>
我不知道,如果错误与使用TestNG到powermock或我做我的代码中一些错误的定义。
@PrepareForTest(MockitoBusinessOperation.class)
@Test(enabled = true)
public void testReCalculatePrepaids() throws Exception {
MockitoBusinessOperation MockitoBusinessOperation = PowerMock.createPartialMock(MockitoBusinessOperation.class, "inTestMethod");
PowerMock.expectPrivate(MockitoBusinessOperation, "inTestMethod", Id).andReturn("working fine");
when(MockitoBusinessService.creditReport(this.Id)).thenReturn(new String("Decline by only Me"));
String report = MockitoBusinessService.creditReport(this.Id);
String mainReport = MockitoBusinessOperation.creditAproved(this.Id);
}
有人有一个想法或任何线索导致该解决方案
你应该真的考虑在你的编辑器中使用空格而不是制表符,这是w这种格式不会很好地复制。空白空间(1)中的空间量是通用的,而制表符不是。 –
感谢您的格式修复 – jan