Skip to content
Advertisement

Tag: powermock

How to write or mock interface methods available in jar?

Having Method like in above method helperCommands is a interface in my Jar file that contains getDisplayConfirmation() method my question is how can i mock this method i check below link but no help Unit testing of Jar methods in java i’m using below dependency is it mendatory to use powerMockRunner ? or above code is enough to write junit?

Mock a constructor with parameter

I have a class as below: The logic in the constructor A(String test) and check() are the things I am trying to mock. I want any calls like: new A($$$any string$$$).check() returns a dummy string “test”. I tried: But it doesn’t seem to be working. new A($$$any string$$$).check() is still going through the constructor logic instead of fetch the mocked

Mockito/PowerMock: how to reset a mocked static variable in SUT?

I hate to introduce Unit-tests into a legacy code base, but I have to. Up untill now I successfully introduced unit-testing into the legacy code base using Mockito and PowerMock. Worked perfectly well until I met with this situation: in the SUT, there’re several static varibles (which I mocked with the help of PowerMock, mocking static methods and mocking constructors).

Advertisement