JiangYongGang / powermock

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

PowerMockRule does not allow setting test expectations in @Before #421

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Run the following test:

class Foo{
    public static int Bar(){
        throw new RuntimeException();
    }
}

@PrepareForTest({Foo.class})
public class JobWrapperBaseTest1 {
    @Rule
    public PowerMockRule rule = new PowerMockRule();

     @Before
      public void init(){
         PowerMock.mockStatic(Foo.class) ;

         expect(Foo.Bar()).andReturn(42);
    }

    @Test
    public void test(){
        PowerMock.replay(Foo.class);

        int i = Foo.Bar();
        System.out.println(i);
    }
}

What is the expected output? What do you see instead?
Pretty obvious: The way I constructed the example I would expect the test to 
succeed, instead it gets to the line that throws an exception.

What version of the product are you using? On what operating system?
Windows 7, PowerMock 1.4.12

Please provide any additional information below.

Original issue reported on code.google.com by pisar...@gmail.com on 13 Jan 2013 at 7:33

GoogleCodeExporter commented 9 years ago
Thanks for reporting. Please help out if you want this to be fixed anytime soon.

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

GoogleCodeExporter commented 9 years ago
Great! Did you release it yet?

Original comment by pisar...@gmail.com on 24 Jan 2013 at 8:19

GoogleCodeExporter commented 9 years ago
What do you mean?

Original comment by johan.ha...@gmail.com on 24 Jan 2013 at 8:25

GoogleCodeExporter commented 9 years ago
I see that the status is Fixed. Did you release the Fix?

Original comment by pisar...@gmail.com on 24 Jan 2013 at 9:12

GoogleCodeExporter commented 9 years ago
Oh I'm sorry I think selected the wrong status type. Sorry for the confusion.

Original comment by johan.ha...@gmail.com on 24 Jan 2013 at 10:13

GoogleCodeExporter commented 9 years ago
No problem :-) Thanks!

Original comment by pisar...@gmail.com on 24 Jan 2013 at 11:08