vjame

          優化代碼是無止境的
          隨筆 - 65, 文章 - 9, 評論 - 26, 引用 - 0
          數據加載中……

          Junit.3.8.詳解

          import junit.framework.Assert;
          import junit.framework.TestCase;

          import com.test.Largest;

          public class TestLargest extends TestCase {

              Largest l;

              @Override
              
          protected void setUp() throws Exception {
                  l 
          = new Largest();
              }

              
          public void testGetL() {
                  
          int[] array = { 23456734578222999 };
                  
          int result = 0;
                  ;
                  
          try {
                      result 
          = l.getLargest(array);

                  } 
          catch (Exception e) {
                      
          // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
                  Assert.assertEquals(
          999, result);
              }

              
          public void testGetL2() {
                  
          int[] array = {};

                  Throwable tx 
          = null;
                  
          try {
                      l.getLargest(array);
                      Assert.fail();
                  } 
          catch (Exception ex) {
                      tx 
          = ex;
                  }

                  Assert.assertNotNull(tx);
                  Assert.assertEquals(Exception.
          class, tx.getClass());
                  Assert.assertEquals(
          "數組不能為空!", tx.getMessage());

              }

              
          public void testGetL3() {
                  Throwable tx 
          = null;
                  
          try {
                      
          int[] array = null;

                      l.getLargest(array);
                      Assert.fail();
                  } 
          catch (Exception ex) {
                      tx 
          = ex;
                  }
                  Assert.assertNotNull(tx);
                  Assert.assertEquals(Exception.
          class, tx.getClass());
                  Assert.assertEquals(
          "數組不能為空!", tx.getMessage());
              }
          }

          posted on 2009-01-20 12:01 lanjh 閱讀(260) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 临江市| 玉林市| 广南县| 德惠市| 衡阳县| 镇远县| 唐山市| 丰顺县| 泸西县| 海伦市| 建瓯市| 阳东县| 邓州市| 韶山市| 湖南省| 吉安县| 灌云县| 邮箱| 郁南县| 青阳县| 房产| 昆明市| 奉化市| 敦煌市| 桐柏县| 刚察县| 三明市| 安宁市| 榆社县| 安西县| 磴口县| 荆州市| 比如县| 临汾市| 桦南县| 海口市| 宜兰县| 凤山市| 祁连县| 布拖县| 兴海县|