我的漫漫程序之旅

          專注于JavaWeb開發(fā)
          隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0
          數(shù)據(jù)加載中……

          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)  編輯  收藏 所屬分類: 軟件測試

          主站蜘蛛池模板: 桦川县| 姚安县| 哈尔滨市| 花莲市| 台东市| 曲水县| 宁城县| 湄潭县| 神池县| 济南市| 万源市| 营山县| 阿拉尔市| 克东县| 包头市| 乡宁县| 滦南县| 昌平区| 哈密市| 湄潭县| 铜鼓县| 股票| 兰州市| 亳州市| 威宁| 普格县| 临武县| 辛集市| 广汉市| 西宁市| 永康市| 大渡口区| 阜新| 三明市| 长宁县| 福贡县| 易门县| 商南县| 桓仁| 富蕴县| 女性|