If its possible to encapsulate static method invocations into an instance method then we can use a *spy* to mock the new instance methods on a real object, that way you could get around mocking statics.
But if a class is using lot of different static methods, then creating instance method for each static method may not be feasible. So +1 Sai On Thu, Dec 17, 2015 at 10:36 AM, Jovaughn Lockridge <[email protected]> wrote: > Why should you factor out static code? Is it because it is hard to test? > > Sent from my iPhone > > > On Dec 17, 2015, at 1:14 PM, Jens Deppe <[email protected]> wrote: > > > > Hey All, > > > > I've just had a need to mock some static methods. Mockito doesn't > > allow mocking statics, but PowerMock does. > > > > Kirk suggested to put this up for discussion before going ahead to use > > PowerMock. Does anyone have any (bad) experience with PowerMock or > > other reservations about using it. > > > > More generally, we should obviously be trying to factor out as much > > static code as possible, but sometimes that's not reasonable to do (at > > least in the short term). > > > > Thoughts? Comments? > > > > Thanks > > --Jens > -- Sai Boorlagadda
