第三次作业
新建junit test case:JunitTest001.java
1 package JunitTestSample001; 2 3 import junit.framework.TestCase; 4 5 import org.junit.After; 6 import org.junit.Before; 7 import org.junit.Test; 8 9 import testsample001.check; 10 11 public class JunitTest001 extends TestCase { 12 13 @Before 14 public void setUp() throws Exception { 15 super.setUp(); 16 } 17 18 @After 19 public void tearDown() throws Exception { 20 super.tearDown(); 21 } 22 23 @Test 24 public void testsearchresult() { 25 // fail("Not yet implemented"); 26 check cooner = new check(); 27 cooner.ConnectOracle("1"); 28 assertEquals("查询结果匹配情况", "防伪码存在!", cooner.ConnectOracle("1")); 29 30 } 31 }
运行JunitTest001.java(Run As-Junit test),运行结果如下: