import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; import mockit.Expectations; import mockit.Mocked; import org.junit.Test; public class LibraryTest { @Mocked @Test public void testModuleOne() { new Expectations() {{ externalModule.doSomething(); result = "Mocked response"; }}; Library library = new Library(externalModule); String result = library.moduleOne(); assertThat(result, is("Mocked response")); } @Test public void testModuleTwo() { new Expectations() {{ externalModule.doSomethingElse(); result = "Mocked response"; }}; Library library = new Library(externalModule); String result = library.moduleTwo(); assertThat(result, is("Mocked response")); } }


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