举例一个空的测试用例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Map; public class MyTest { Map dict_para = new HashMap(); @Test // 测试1 public void testMy1() { dict_para.clear(); dict_para.put("useSSL", "unknow"); MyDemo m1 = new MyDemo(dict_para); boolean ret = m1.do1(); Assert.assertEquals(false, ret); } } |
编译: javac -cp ".:/opt/jdk-17/lib/junit-4.13.2.jar" MyTest.java 运行: java -cp ".:/opt/jdk-17/lib/junit-4.13.2.jar:/opt/jdk-17/lib/hamcrest-core-1.3.ja […]