我的漫漫程序之旅

          專注于JavaWeb開發
          隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0
          數據加載中……

          TestSuite集合測試的使用

          有時候需要一次測試所有的類(或多個),這時候就用到了TestSuite.
          舉例說明:
          這里有兩個TestCase類.
          Person:

          package com;
          import junit.framework.TestCase;
          public class Person extends TestCase
          {
           
          public void testMethod1()
           
          {
            System.out.println(
          "Person:method1");
           }

           
           
          public void testMethod2()
           
          {
            System.out.println(
          "Person:method2");
           }

           
           
          }


          Student:

          package com;
          import junit.framework.TestCase;
          public class Student extends TestCase
          {
           
          public void testMethod()
           
          {
            System.out.println(
          "Student:method");
           }

          }


          集合測試的類:PersonSuite

          package com;
          import junit.awtui.TestRunner;
          import junit.framework.Test;
          import junit.framework.TestCase;
          import junit.framework.TestSuite;
          public class PersonSuite extends TestCase
          {
           
          public static Test suite()
           
          {
            TestSuite ts 
          = new TestSuite();
            ts.addTestSuite(Person.
          class);
            ts.addTestSuite(Student.
          class);
            
          return ts;
           }

           
           
          public static void main(String[] args)
           
          {
            
          //用TestRunner呼叫suite 方法
            TestRunner.run(PersonSuite.class);
           }

          }



          posted on 2007-11-24 08:50 々上善若水々 閱讀(1179) 評論(0)  編輯  收藏 所屬分類: 軟件測試

          主站蜘蛛池模板: 扶余县| 蒙城县| 澳门| 鄂托克前旗| 淮阳县| 东乌| 遂川县| 察雅县| 视频| 宁晋县| 军事| 兴隆县| 峨边| 抚宁县| 满城县| 奎屯市| 科尔| 大关县| 望城县| 秭归县| 诏安县| 石柱| 文登市| 和田县| 新蔡县| 黔东| 浦城县| 泸西县| 寻乌县| 新龙县| 黄大仙区| 华宁县| 双江| 通化市| 信阳市| 凤庆县| 镇坪县| 玉门市| 偏关县| 卢龙县| 囊谦县|