wujun / powermock

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

initializationError occured when run a single method as JUnit test with PowerMockRunner #508

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.In Eclipse, select one method of class TestClassUnderTest, then right click 
and select "Run As > JUnit Test". 

What is the expected output? What do you see instead?
In JUnit View : 
         dummy[Runner JUnit4]
         Unrooted Tests[Runner JUnit4](0.000s)
           initialization error
It works fine in the following situations:
  1.  Select the whole class in Project Explorer and then run as JUnit Tests;
  2.  Leave only one test method in the test class;
  3.  In test classes without PowerMockRunner.  

What version of the product are you using? On what operating system?
Eclipse : Kepler Service Release 1, Build id: 20130919-0819
          JUnit Testing Framework plug-in : 4.11.0.v201303080030
          PDE JUnit Runtime Support plugin: 3.4.300.v20130422-2046
JUnit : 4.11
powermock-core、powermock-module-junit4 : 1.5.5

Please provide any additional information below.

Original issue reported on code.google.com by liubao2...@gmail.com on 31 Jul 2014 at 8:16

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I have seen this before. In my case I had -XX:-UseSplitVerifier in my maven 
plugin in the pom. However, this is in eclipse, I had to create a special run 
configuration that would test the single method with -XX:-UseSplitVerifier as a 
vm arguement.

Original comment by swhite00...@gmail.com on 10 Dec 2014 at 9:41

GoogleCodeExporter commented 9 years ago
Also seeing this problem.  

Eclipse: Luna Service Release 1 (4.4.1) Build id: 20140925-1800          
JUnit Testing Framework plug-in : 4.11.0.v201303080030
PDE JUnit Runtime Support plugin: 3.4.300.v20130422-2046
JUnit : 4.11
powermock-core, powermock-module-junit4 : 1.5.4

@swhite00, not sure if you are suggesting that this VM argument should fix this 
issue or not, but it does not in my case.

Original comment by jordangl...@gmail.com on 13 Dec 2014 at 4:50

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I faced the same problem. Forget about -XX:-UseSplitVerifier.

Solution: Put the @PrepareForTest(ClassUnderTest.class) annotation to the 
class-level of the test class as described at 
https://code.google.com/p/powermock/wiki/MockStatic.

As soon as you have changed this everything works as expected.

Original comment by matthias...@gmail.com on 5 Feb 2015 at 4:26