如果您在flexunit 3中创建了一个纯ActionScript项目,并且希望使用flexunit进行单元测试,那么最好的选择是什么?
内置Flex构建器将拒绝构建包含TestRunnerBase组件的mxml文件,因为它是一个纯ActionScript项目(不允许使用Flex )。不可能将mxml文件添加到项目设置中的"ActionScript应用程序“列表中。
现在我可以看到两种选择,都是不可取的。
发布于 2008-12-14 13:31:12
总有ASUnit。
发布于 2008-12-14 17:10:53
最后,我将单元测试mxml文件放在原始项目中,创建了一个新的Flex项目,删除了src目录,并将其替换为一个指向ActionScript项目的src目录的Eclipse链接文件夹。这个设置似乎很好。
发布于 2008-12-15 09:39:10
为了让FlexUnit与CruiseControl.net (连续集成服务器)一起工作,我们做了一些类似的事情。
在我们的实现中,下面的代码运行在应用程序类的FlexEvent.CREATION_COMPLETE处理程序中。
如何输出单元测试的结果完全取决于您。我们的实现已经与AIR和Zinc3一起使用,并且都输出了一个NUnit友好的XML表示,然后退出应用程序(如果任何测试失败,退出代码为-1 )。
// import mx.core.Application;
// import flexunit.framework.*;
// class AutomatedTestHarness extends Application implements TestListener
private function creationCompleteHandler(event : Event) : void
{
this._result = new TestResult();
this._result.addListener(this);
var testSuite : TestSuite = new TestSuite();
this.addUnitTests(testSuite);
testSuite.runWithResult(_result);
}
/**
* Implement these as part of TestResult.addListener
* If you want to output xml after the tests run, do so here
* (Tip: Count tests in endTest and compare the count to testSuite.countTestCases()
* to find out when all tests have completed)
*/
function startTest(test : Test) : void {}
function endTest(test : Test) : void {}
function addError(test : Test, error : Error) : void {}
function addFailure(test : Test, error : AssertionFailedError) : void {}https://stackoverflow.com/questions/366088
复制相似问题