Hi
I have a problem with the mocking of static methods. My code looks something like this:
@RunWith(PowerMockRunner.class)
@PrepareForTest(SomeClassWithStaticMethod.class)
public class TestClass {
@Before
public void setUp(){
MockServiceFactory.initMockService();
PowerMock.mockStatic(SomeClassWithStaticMethod.class);
PowerMock.replayAll();}
public void someTest(){
//test impl
}
}
Here the class for MockServiceFactory:
@PrepareForTest(ServiceFactroy.class)
public class MockServiceFactory{
public static void initMockService(){
ServiceFactory s = PowerMock.createMock(ServiceFactory.class); //ServiceFactory is the class I actually want to mock
PowerMock.mockStatic(ServiceFactory.class);
//some more code
}
}
As you can see I want to call mockStatic in two different classes once in my Test and once in a Factory class that creates mock objects for ServiceFactory.
How can I make this code running? Because running it always results in:
java.lang.IllegalStateException: no last call on a mock available
at org.easymock.EasyMock.getControlForLastCall(EasyMock.java:520)
at org.easymock.EasyMock.expect(EasyMock.java:498)
...
Thank you for your help!!!--
You received this message because you are subscribed to the Google Groups "PowerMock" group.
To unsubscribe from this group and stop receiving emails from it, send an email to powermock+...@googlegroups.com.
To post to this group, send email to powe...@googlegroups.com.
Visit this group at http://groups.google.com/group/powermock?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.