OK, so I’ve been using Eclipse more and more. One thing I missed about it while using ASUnit is the missing Create Classes command that you can run from the Flash IDE. This recursively creates AllTests classes in each directory of your package, down to the class you are writing a test for, and creates a TestCase class for the specificy class. Using FAME, you have to write all of these yourself. I did this once, and that was enough. Then I created templates to do it for me after this:
AllTests:
import com.asunit.framework.*;
class AllTests extends TestSuite {
private var className:String = "AllTests";
public function AllTests()
{
super();
addTest(new ${package}.AllTests());
// and/or add specific tests here
}
}
TestCase:
import ${package}.*;
import com.asunit.framework.*;
class ${package}.${className} extends TestCase {
private var className:String = "${package}.${className}";
private var instance:${className};
public function setUp():Void {
instance = new ${className}();
}
public function tearDown():Void {
delete instance;
}
public function testInstantiated():Void {
assertTrue("${className} instantiated", instance instanceof ${className});
}
}
Just go to Windows/Preferences/ActionScript 2/Templates. Click “New…”, add name and description and paste the code.
Now, in an .as file, type “TestCase” or “AllTests” and hit control-space. You’ll be prompted for the needed info to finish the class.