[java]代码库
package cn.outofmemory.junit.mock;
import mockit.Mock;
import mockit.Mockit;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class ServiceFactoryTest {
@Test
public void should_return_mock_service() {
Mockit.setUpMock(ServiceFactory.class, ServiceFactoryStub.class);
assertEquals("mock service", ServiceFactory.getAService());
}
private static class ServiceFactoryStub {
@Mock
public static String getAService() {
return "mock service";
}
}
}
//源代码片段来自云代码http://yuncode.net