發表文章

目前顯示的是 10月, 2013的文章

簡單的Junit4 case

在junit4的架構下,直接用 Annotation表示要執行的test method import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; /* * if unit test need run many times with different parameter and result */ @RunWith(Parameterized.class) public class IPUtil_UT_HasIP {         private List<String> ipList;     private String ip;     private boolean result;         @SuppressWarnings("rawtypes")     @Parameters     public static Collection data()  {         List<String> ips = new ArrayList<String>(300);         for(int i= 1;i<256;i++){             ips.add("192.168.1."+i);         }         ips.add("127.0.58.32");         return Arrays.asLi