Unable to mock constructor inside enum method

9 views
Skip to first unread message

Laosi Ding

unread,
Aug 26, 2021, 5:27:34 AM8/26/21
to PowerMock
Hi,

In below example, I'm trying to mock e.set() method to throw Exception. However, I tried mockStatic + doThrow(Exception).when(e).set() and prepared for class E and R, but still not able to mock set method since no exception was thrown. Just wonder is it a known issue in powermockito, or I missed something here?

This might be some similar question:


public enum R implements I{
 R1 {
     xxx
 }
R2 {
    @Override
    public I method1(){
         E e = new E();
         e.set();
    }
}
}


------
//some other class named E
public void set() throws Exception{
    xxx
}


Thanks

Reply all
Reply to author
Forward
0 new messages