I am using powermock.mockstatic this line blow so that I can control its returning value since its only swing I dont have to test it.
@Before
public void setUp() throws Exception
RelatedIntelligencePanel rel = Mockito.mock(RelatedIntelligencePanel.class);
PowerMockito.mockStatic(RelatedIntelligencePanel.class);
PowerMockito.whenNew(RelatedIntelligencePanel.class).withNoArguments().thenReturn(rel);
...
.. some other unrelated code
}
...........
........ some other code and Tests
......
@Test
public class SomeClass{
RelatedIntelligencePanel relIntPanel = new RelatedIntelligencePanel();
But it throws java.lang.VerifyError. I did plenty of mocking this kind of thing and there was no exception like that. Removing @PrepareForTest and @Runwith helps but I lose powermock when I do that. My detailed error is also below ;
java.lang.VerifyError: Bad return type
Exception Details:
Location:
javax/swing/plaf/metal/MetalLookAndFeel.getLayoutStyle()Ljavax/swing/LayoutStyle @3: areturn
Reason:
Type 'javax/swing/plaf/metal/MetalLookAndFeel$MetalLayoutStyle' (current frame, stack[0]) is not assignable to 'javax/swing/LayoutStyle' (from method signature)
Current Frame:
bci: @3
flags: { }
locals: { 'javax/swing/plaf/metal/MetalLookAndFeel'}
stack {'javax/swing/plaf/metal/MetalLookAndFeel$MetalLayoutStyle'}
Bytecode:
0x0000000: b807 49b0