FlexUnit小小应用
2008-11-04 12:46
113 查看
类似JUnit,之前稍微研究过。现在简单介绍下FlexUnit的简单应用:首先去adobe open source下载FLEXUNIT
网址:http://opensource.adobe.com/wiki/display/flexunit/Downloads
在你建立好的项目中导入该swc,(此步骤就不介绍了^-^).
index.mxml (亦可是别的mxml)模拟:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:flexui="flexunit.flexui.*"
creationComplete="init()" layout="absolute" >
<mx:Script>
<![CDATA[
//import some class yourself
private function createTestSuite():TestSuite
{
var testSuite:TestSuite = new TestSuite();
testSuite.addTest(new SimpleTest("testConvertIsDesc"));
return testSuite;
}
internal function init():void
{
///////////////////////////TestUnit//////////////////////////////
testRunner.test = createTestSuite();
testRunner.startTest();
/////////////////////////////////////////////////////////////////
}
]]>
</mx:Script>
<flexui:TestRunnerBase id="testRunner" width="100%" height="100%"/>
</mx:Application>
SimpleTest.as------>code
package com.jerry.tests
{
import flexunit.framework.TestCase;
import flexunit.framework.Assert;
public class SimpleTest extends TestCase
{
public function SimpleTest(methodName:String=null)
{
super(methodName);
}
// 测试方法 ConvertToIsDesc
public function testConvertIsDesc():void
{
var simple:SimpleConverter = new SimpleConverter();
var desc:String = simple.ConvertToIsDesc(1);
Assert.assertEquals(desc, "是");
}
}
SimpleConverter.as---->code
package com.jerry.tests
{
public class SimpleConverter
{
public function SimpleConverter()
{
// 构造函数
}
// 需要测试的方法
public function ConvertToIsDesc(i:int):String
{
var isDesc:String = "否";
if(i == 1)
{
isDesc = "是";
}
return isDesc;
}
}
}
}
网址:http://opensource.adobe.com/wiki/display/flexunit/Downloads
在你建立好的项目中导入该swc,(此步骤就不介绍了^-^).
index.mxml (亦可是别的mxml)模拟:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:flexui="flexunit.flexui.*"
creationComplete="init()" layout="absolute" >
<mx:Script>
<![CDATA[
//import some class yourself
private function createTestSuite():TestSuite
{
var testSuite:TestSuite = new TestSuite();
testSuite.addTest(new SimpleTest("testConvertIsDesc"));
return testSuite;
}
internal function init():void
{
///////////////////////////TestUnit//////////////////////////////
testRunner.test = createTestSuite();
testRunner.startTest();
/////////////////////////////////////////////////////////////////
}
]]>
</mx:Script>
<flexui:TestRunnerBase id="testRunner" width="100%" height="100%"/>
</mx:Application>
SimpleTest.as------>code
package com.jerry.tests
{
import flexunit.framework.TestCase;
import flexunit.framework.Assert;
public class SimpleTest extends TestCase
{
public function SimpleTest(methodName:String=null)
{
super(methodName);
}
// 测试方法 ConvertToIsDesc
public function testConvertIsDesc():void
{
var simple:SimpleConverter = new SimpleConverter();
var desc:String = simple.ConvertToIsDesc(1);
Assert.assertEquals(desc, "是");
}
}
SimpleConverter.as---->code
package com.jerry.tests
{
public class SimpleConverter
{
public function SimpleConverter()
{
// 构造函数
}
// 需要测试的方法
public function ConvertToIsDesc(i:int):String
{
var isDesc:String = "否";
if(i == 1)
{
isDesc = "是";
}
return isDesc;
}
}
}
}
相关文章推荐
- as3.0----flash复制功能在网页上面的小小应用
- 游标的应用,一个小小的功能,做一下记录
- 小小词典(三,应用图标与启动画面)
- WPF 3D 小小小小引擎 - ·WPF 3D变换应用
- 栈的一些小小应用
- 小程序大问题,MSDN中一个小小示例所带来的疑问,一个关于DataList的一个简单应用
- Android EditText 应用小小结
- WPF 3D 小小小小引擎 - ·WPF 3D变换应用
- DispatcherTimer与Dispatcher小小应用
- 我是菜鸟之小小项目开发经历(三)------第一个应用系统开发
- 关于逻辑或的一个小小应用注意点
- ffserver.conf配置小解以及小小测试应用
- 一个小小的mui ajax查询应用
- 关于Split的小小应用
- 结构体小小应用
- WinForm小小应用
- python局部变量与全局变量,global的演练应用与nonlocal的小小上演
- vector的小小应用,大大功能
- Bitmap中的getPixels方法的小小应用
- 结构体小小应用