import org.junit.Test; import static org.junit.Assert.*; public class MyLibraryTest { @Test public void testAdd() { MyLibrary library = new MyLibrary(); int result = library.add(2, 3); assertEquals(5, result); } } import org.junit.Test; import mockit.Mocked; import static org.junit.Assert.*; import static mockit.Deencapsulation.*; public class MyLibraryTest { @Mocked ExternalDependency dependency; @Test public void testLibraryWithDependency() { MyLibrary library = new MyLibrary(); int result = library.doSomethingWithDependency(); assertEquals(10, result); } static class ExternalDependency { public int getValue() { return 10; } } }


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