vjame

          優(yōu)化代碼是無止境的
          隨筆 - 65, 文章 - 9, 評(píng)論 - 26, 引用 - 0
          數(shù)據(jù)加載中……

          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(
          "數(shù)組不能為空!", 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(
          "數(shù)組不能為空!", tx.getMessage());
              }
          }

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


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 新邵县| 屏山县| 凉城县| 石阡县| 蚌埠市| 平陆县| 西丰县| 泊头市| 铁岭市| 教育| 凉山| 郁南县| 泰安市| 龙游县| 平谷区| 南澳县| 嘉定区| 普格县| 沛县| 临湘市| 天台县| 达州市| 西吉县| 逊克县| 芦山县| 故城县| 句容市| 临澧县| 措美县| 耿马| 安平县| 海城市| 山阴县| 烟台市| 邹平县| 潮州市| 社旗县| 宁德市| 桦南县| 澳门| 茶陵县|