My favorites | Sign in
Project Logo
                
Search
for
Updated Nov 10, 2008 by johan.haleby
Labels: Usage
MockPartial  

Partial Mocking

Quick summary

  1. Use the @RunWith(PowerMockRunner.class) annotation at the class-level of the test case.
  2. Use the @PrepareForTest(ClassToPartiallyMock.class) annotation at the class-level of the test case.
  3. se PowerMock.createPartialMock(ClassToPartiallyMock.class, "nameOfTheFirstMethodToMock", "nameOfTheSecondMethodToMock") to create a mock object that only mocks the methods with name nameOfTheFirstMethodToMock and nameOfTheSecondMethodToMock in this class (let's call it mockObject).
  4. Use PowerMock.replay(mockObject) to change the mock object to replay mode.
  5. Use PowerMock.verify(mockObject) to change the mock object to verify mode.

Example

TODO

References

TODO



Sign in to add a comment
Hosted by Google Code