-
Notifications
You must be signed in to change notification settings - Fork 586
MockPartial
Arthur Zagretdinov edited this page Jun 15, 2017
·
2 revisions
- Use the
@RunWith(PowerMockRunner.class)
annotation at the class-level of the test case. - Use the
@PrepareForTest(ClassToPartiallyMock.class)
annotation at the class-level of the test case. - se
PowerMock.createPartialMock(ClassToPartiallyMock.class, "nameOfTheFirstMethodToMock", "nameOfTheSecondMethodToMock")
to create a mock object that only mocks the methods with namenameOfTheFirstMethodToMock
andnameOfTheSecondMethodToMock
in this class (let's call itmockObject
). - Use
PowerMock.replay(mockObject)
to change the mock object to replay mode. - Use
PowerMock.verify(mockObject)
to change the mock object to verify mode.