Do with PowewrMock something like MockUp from JMockit

29 views
Skip to first unread message

Luís Brito

unread,
Oct 25, 2019, 5:00:16 PM10/25/19
to PowerMock
Hello.

I want to do something similar to 'MockUp' from JMockit but with Mockit/PowerMock.

I want to control the comportment of a method of a class that extends the class i want to test.
But i have one problem that is  the method is private, so i think i cant go with Mockito, and need use PowerMock.

The Problem

   
 Class A extends B{...}


   
Class B {
     
private Header generateHeaderForServiceCall(c,d,f,g,h,j){...}
   
}


In my Class ATest{ In @Before i want to mock generateHeaderForServiceCall(.....) for just return a default Header created for me. }

So, using JMockit is like:

   
 new MockUp<Controller>() {
     
@Mock
     
private Header generateHeaderForServiceCall(...) {
       
return defaultHeader;
     
}
   
};


* So, can i do with with Mockito?

* Do i need to use PowerMock?

* Can i use Mockito and PowerMockit together?

Thanks
Reply all
Reply to author
Forward
0 new messages