import mockit.Injectable; import mockit.Mock; import mockit.MockUp; import org.junit.Assert; import org.junit.Test; public class ExampleTest { @Injectable private Dependency dependency; @Test public void testExampleMethod() { new MockUp<Dependency>() { @Mock public int getValue() { return 10; } }; Example example = new Example(dependency); int result = example.exampleMethod(); Assert.assertEquals(20, result); } }


上一篇:
下一篇:
切换中文