tiebin-zhang / powermock

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

unable to use @Rule with junit 4.10 #384

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

PowerMockJUnit47RunnerDelegateImpl throws a ClassCastException at line 79 : 
MethodRule rule = (MethodRule) field.get(testInstance);

Rules in junit 4.10 implement TestRule, not MethodRule.

Here is a simple testcase:

@RunWith(PowerMockRunner.class)
public class PowerMockBug {

 @Rule
 public MyRule rule = new MyRule();

 @Test
 public void testFoo() {
  System.out.println("testing foo");
 }

 public static class MyRule implements TestRule {

   @Override
   public Statement apply(Statement base, Description description) {
     return base;
   }
 }
}

Original issue reported on code.google.com by karl.via...@gmail.com on 3 May 2012 at 3:09

GoogleCodeExporter commented 9 years ago
:/ duplicate of 344, sorry

Original comment by karl.via...@gmail.com on 3 May 2012 at 3:12

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 10 May 2012 at 7:22