vjame

          優(yōu)化代碼是無止境的
          隨筆 - 65, 文章 - 9, 評論 - 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 閱讀(260) 評論(0)  編輯  收藏


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 枣庄市| 黑山县| 思南县| 读书| 白城市| 龙里县| 安新县| 安丘市| 周宁县| 凤凰县| 滕州市| 临武县| 菏泽市| 吴江市| 响水县| 肇州县| 通州区| 昭通市| 永福县| 东乌珠穆沁旗| 盐津县| 吉林省| 拜城县| 霍山县| 大港区| 九江市| 黑水县| 灵丘县| 惠州市| 会昌县| 哈巴河县| 邯郸市| 隆子县| 德格县| 灵寿县| 翼城县| 吉林省| 岱山县| 简阳市| 赤壁市| 崇左市|