[osflash] ASUnit Templates for Eclipse

Keith Peters kp at bit-101.com
Mon Jun 13 13:46:39 PDT 2005


One thing I missed about Eclipse is the missing Create Classes command.
These templates should help:


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.





More information about the osflash mailing list