tiebin-zhang / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

Use mockStatic() on a class occurs a NullPointerException in a switch which uses an Enum value when calling the instance method containing the switch #374

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
=> please use the provided archive to launch the JUnit test

What is the expected output? What do you see instead?
=> I expect that no NullPointerExcetpion occurs in the switch using Enum in an 
instance method.

What version of the product are you using? On what operating system?
- mockito-all-1.8.5.jar
- powermock-mockito-1.4.9-full.jar

OS: Ubuntu 10.04.3 LTS

Additional information:

Like I need to mock any static methods of a class but no need to mock the 
instance methods, I used mockStatic(). Maybe I don't use it correctly and we 
can't expect correct execution of instance methods if using mockStatic() ? Yet, 
except this error case it seems to call the real instance methods correctly.

Thank you for your help,

Axel

Original issue reported on code.google.com by axelm79 on 29 Feb 2012 at 10:39

Attachments:

GoogleCodeExporter commented 9 years ago
I have observed the same behavior.  If I call mockStatic then later on when I 
call a method of that class which has a switch statement I get 
NullPointerException when evaluating the first case in a switch statement.  I 
have the following:

OS: Windows 7

org.mockito
mockito-all
1.9.5

org.powermoc
powermock-api-mockito
1.5

Original comment by rydan...@gmail.com on 9 Feb 2013 at 3:57

GoogleCodeExporter commented 9 years ago
Could you provide a patch?

Original comment by johan.ha...@gmail.com on 9 Feb 2013 at 8:51