noushadali / powermock

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

whenNew dos not work when final class and final method are mocked together. #448

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I have class : 

public final class A
{
   public final void foo(){
       System.out.println("foo");
   }

}
Both class and method are final.

This is my test:

@RunWith(PowerMockRunner.class)
@PrepareForTest({ A.class })
public class Tester2
{

    @Test
    public void test(){
        A a = mock( A.class );
        a.foo();

    }

}

the test prints "foo", it means real method was called@
but I call the mock, so nothing should be printed !
If I remove the final from the method, it works fine, the problem occurs only 
if both class and method are final.

What is the expected output? What do you see instead?
I am expecting the mocked method to be called, instead the real method is called

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

Original issue reported on code.google.com by mohamed....@gmail.com on 17 Jun 2013 at 1:41