vijayjcp / powermock

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

@RunWith(PowerMockRunner.class) failed with Junit4 ExpectedException Rule #416

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. see attached unit test

What is the expected output? What do you see instead?
As is :
 Running this test with @RunWith(PowerMockRunner.class) will failed
 Running this test without @RunWith(PowerMockRunner.class) will suceed
Expected :
 using @RunWith(PowerMockRunner.class) should not failed the test.

What version of the product are you using? On what operating system?
junit.version 4.11
powermock.version 1.5
java 1.6.0_18
Windows 7

Please provide any additional information below.

Original issue reported on code.google.com by yvesdm on 7 Dec 2012 at 1:46

Attachments:

GoogleCodeExporter commented 8 years ago
I have a similar issue.  It seems to be a hamcrest version problem.

Original comment by tim.br...@gmail.com on 11 Dec 2012 at 4:43

GoogleCodeExporter commented 8 years ago
Yes Hamcrest versioning can be a nightmare if you have other projects in your 
classpath that uses another version of Hamcrest. Unfortunately I don't think 
PowerMock can do anything about this.

Original comment by johan.ha...@gmail.com on 22 Jan 2013 at 7:27

GoogleCodeExporter commented 8 years ago
I have the same issue, using powermock 1.4.12, junit 4.11 and mockito 1.9.0.
THis results in the following stacktrace:

java.lang.ClassCastException: org.junit.rules.ExpectedException cannot be cast 
to org.junit.rules.MethodRule
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:79)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:284)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:209)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:148)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
    at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:102)
    at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
    at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:42)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)

Original comment by sander.s...@jdriven.com on 14 Mar 2013 at 9:47

GoogleCodeExporter commented 8 years ago
Try latest trunk

Original comment by johan.ha...@gmail.com on 15 Mar 2013 at 6:32