Wednesday, March 23, 2016

Common PowerMock and EasyMock Use Cases and Properties

Hand-rolled Mocks
  • They're Fast

EasyMock
  • Use when a Hand-rolled mock will be very large and/or cumbersome
  • If you do not need any PowerMock features

 PowerMock
  • Hard to trace using debugger
  • If you need assumptions about the internal code that cannot be reached by EasyMock
  • For testing with statics and singletons
  • For testing difficult to mock classes like java.io.File
  • For accessing private fields
  • For suppressing methods