随笔 - 7  文章 - 0 评论 - 5 
<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(2)

随笔分类

随笔档案

相册

搜索

  •  

最新评论

阅读排行榜

评论排行榜

example.SimpleConverter类代码:
 1 package example
 2 {
 3     /*******************************
 4     * 定义需要测试的类 SimpleConverter
 5     *******************************/
 6     public class SimpleConverter
 7     {
 8         public function SimpleConverter()
 9         {
10             // 构造函数
11         }
12         
13         // 需要测试的方法
14         public function ConvertToIsDesc(i:int):String
15         {
16             var isDesc:String = "";
17             if(i == 1)
18             {
19                 isDesc = "";
20             }
21             
22             return isDesc;
23         }
24     }
25 }
tests.SimpleTest类代码:
 1 package tests
 2 {
 3     /*******************************
 4     * 定义 SimpleConverter 的测试类 
 5     *******************************/
 6     import flexunit.framework.TestCase;
 7     import flexunit.framework.Assert;
 8     import example.SimpleConverter;
 9 
10     public class SimpleTest extends TestCase
11     {
12         public function SimpleTest(method:String):void
13         {
14             super(method);
15         }
16         
17         // 测试方法 ConvertToIsDesc 
18         public function testConvertIsDesc():void
19         {
20             var simple:SimpleConverter = new SimpleConverter();
21               var desc:String = simple.ConvertToIsDesc(1);
22               Assert.assertEquals(desc, "");
23         }
24     }
25 }
index.mxml代码:
 1 <?xml version="1.0" encoding="utf-8"?>
 2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
 3      initialize="initializeHandler(event)" xmlns:flexui="flexunit.flexui.*">
 4 
 5     <mx:Script>
 6         <![CDATA[
 7             import flexunit.framework.TestSuite;
 8             import tests.SimpleTest;
 9             
10             private function initializeHandler(event:Event):void
11             {
12                 //  调用测试类,测试ConvertIsDesc方法
13                 var suite:TestSuite = new TestSuite();
14                 // 这里可以增加N个addTest方法,测试不同的类
15                 suite.addTest(new SimpleTest("testConvertIsDesc"));
16                 // 开始测试
17                 testRunner.test = suite;
18                 testRunner.startTest();
19             }
20         ]]>
21     </mx:Script>
22     
23     <flexui:TestRunnerBase id="testRunner" width="100%" height="100%" />
24     
25 </mx:Application>
posted on 2007-09-20 12:57 Lalo 阅读(1749) 评论(0)  编辑 收藏 引用 所属分类: Flex
只有注册用户登录后才能发表评论。