本来自己写了一个小的Framework,起名字的时候在网上顺便搜了一下,发现有人写的狠好的Framework- AsUnit., 可以狠好的集成在Flash MX IDE上.
1. 下载安装一个Macromedia Extension Manager
2. 下载AsUnit, 点击运行AsUnit.mxp,即可
---------------------------------------
QUICKSTART INSTRUCTIONS:
---------------------------------------
- Open Flash MX Professional 2004
- Create a new .fla file, name it "Example.fla" and save it to a NEW and EMPTY directory
on your computer.
*NOTE: There is deep recursive search and file creation associated with the
automated creation of Test Suites. This will cause undesired behavior if executed
outside of a project-only directory.
- Open the Native Flash Output Panel if it's not already open (Window >> Development
Panels >> Output or F2)
- Click Window >> Other Panels >> AsUnit Ui
- Dock the AsUnit Ui underneath (or above) the Output Panel
* I try to save this panel set by choosing Window >> Save Panel Layout because sometimes
Flash will hide your panels for some crazy reason!
- Choose Commands >> Create Class
- In the pop-up window, type "com.asunit.example.ExampleClass" (without the quotes)
- Select:
"Automatically Open New Files"
"Add to Library as MovieClip"
"Add new Test
and be sure that "Prefix Class Name with __Packages" is deselected.
- Click OK
- Select frame 1 of your new movie and open the Actions Panel (Window >> Development
Panels >> Actions or F9)
- In the Actions Panel, type:
var at:AllTests = new AllTests();
- Test the Movie (Control >> Test Movie or CTRL+ENTER)
* Make sure that the Output Panel and Unit Test Panel both stay open. You can open the
Output Panel by pressing F2.
The Unit Test UI Panel should say something like, "1 of 2 Asserts Passed". This is
desired behavior because the new TestCase Template includes 2 assertions. The first one
instantiates the newly-created class and asserts it's data type. This should be passing.
* You should be able to click on the underlined portion of the Failing Test in the AsUnit Panel
To open the .as file directly.
The second assertion is a failing assertion that will provide immediate notification that
the newly-created TestCase is actually being executed.
- Now go to com/asunit/example and open ExampleClassTest.as (From wherever you saved your
.FLA file.)
- Change line 22 from:
assertTrue("failingtest", false);
to:
assertTrue("passingtest", true);
- Now Compile and you should have 2 of 2 Assertions passing.