`

mock System class with powermock

 
阅读更多

 

  1. Use the @RunWith(PowerMockRunner.class) annotation at the class-level of the test case.
  2. Use the @PrepareForTest({ClassThatCallsTheSystemClass.class}) annotation at the class-level of the test case.
  3. Use mockStatic(SystemClass.class) to mock the system class then setup the expectations as normally.
  4. EasyMock only: Use PowerMock.replayAll() to change to replay mode.
  5. EasyMock only: Use PowerMock.verifyAll() to change to verify mode.

ref: https://code.google.com/p/powermock/wiki/MockSystem 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics