skip to main |skip to sidebar

2007-06-03

AUT Framework 入门

Actionscript Unit Test Framework Sample

Actionscript Unit Test Framework Sample

//TestCaseSample1.as
package {
 import advancedflex.debugger.aut.framework.TestCase;
 import advancedflex.debugger.aut.framework.ns.*;

 public class TestCaseSample1 extends TestCase {
  //只测试
  test function a():void {
   console.print("aa");
  }
  //测试并检测是否超时(验证代码的效率时用)
  time function b():int {
   console.print("bb");
   //超时的时间()
   return 10;
  }
 }
}
//TestCaseSample2.as
package {
 import advancedflex.debugger.aut.framework.TestCase;
 import advancedflex.debugger.aut.framework.ns.*;

 public class TestCaseSample2 extends TestCase {
  //只测试 
  test function cc():void {
   console.print("aaa");
  }
  //测试并检测是否超时(验证代码的效率时用)
   time function dd():int {
   console.print("bbb");
   return 10;
  }
 }
}
//Main.as
package {
 import advancedflex.debugger.aut.framework.TraceConsole;
 import advancedflex.debugger.aut.framework.TestSuite;
 
 public class Main {
  public function TestTests() {
   new TestSuite()
   .addTest(new TestCaseSample1())
   .addTest(new TestCaseSample2())
   .startTest(new TraceConsole());
   
  }
  /*你也可以这样写
  public function TestTests() {
   new TestCaseSample1().startTest(new TraceConsole());
   new TestCaseSample2().startTest(new TraceConsole());
   
  }*/
 }
}

没有评论: