You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. Create a project with Spring 3.1.0
2. Create the following classes
import org.springframework.beans.factory.annotation.Configurable;
@Configurable
public class Parent {
}
public class Child extends Parent {
public static int staticMethod() {
throw new RuntimeException("Should not be called, Ever !!!");
}
}
3. Create the following test :
import static junit.framework.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareOnlyThisForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PrepareOnlyThisForTest({ Child.class })
public class UnitTest {
@Before
public void setup() {
PowerMockito.spy(Child.class);
Child child = new Child();
// Commenting this line fails the test
// Child child2 = new Child();
PowerMockito.doReturn(999).when(Child.class);
Child.staticMethod();
}
@Test
public void testStaticMethod() {
assertEquals(999, Child.staticMethod());
}
}
What is the expected output? What do you see instead?
This test fails and should succeed. Uncommenting the child2 makes the test
succeed.
What version of the product are you using? On what operating system?
PowerMock 1.4.2
Spring 3.1.0
Please provide any additional information below.
Original issue reported on code.google.com by benoit.pavot on 28 Jun 2012 at 2:12
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
benoit.pavot
on 28 Jun 2012 at 2:12The text was updated successfully, but these errors were encountered: