chcchangchc / powermock

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

problem in using PowerMock #301

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, I get a problem in using the PowerMock suite. You can copy my Junit test 
file into your project. When you run the BTestForJunit3 class as a Java 
Application, the result will be passed, but when you run the BTestForJunit3 
class as a Junit Test, the result will be failed and a exception will print at 
the console page. I think it is not a correct behavior, what do you think? The 
detail of exception as follow:

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
    at java.util.LinkedList.entry(LinkedList.java:368)
    at java.util.LinkedList.get(LinkedList.java:313)
    at org.powermock.modules.junit3.internal.impl.JUnit3TestSuiteChunkerImpl.testAt(JUnit3TestSuiteChunkerImpl.java:199)
    at org.powermock.modules.junit3.PowerMockSuite.testAt(PowerMockSuite.java:97)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.sendTree(JUnit3TestReference.java:142)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.sendTrees(RemoteTestRunner.java:469)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:457)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

As you see, the version of the junit framework which I'm using is Junit3.8.2. 
Thank you.

Original issue reported on code.google.com by cndoublehero@gmail.com on 20 Dec 2010 at 10:47

Attachments:

GoogleCodeExporter commented 9 years ago
I use the latest version of powermock.I download a  
powermock-easymock-junit-1.4.6.zip file from this site.Thank you.

Original comment by cndoublehero@gmail.com on 20 Dec 2010 at 11:06

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
This is a bug, thanks for your example. A work-around is to move the 
PrepareToTest annotation to the class-level instead of method-level.

Would also really encourage you to upgrade to JUnit 4.

Original comment by johan.ha...@gmail.com on 26 Dec 2010 at 9:55