Hi All,
I'm having real problems trying to get a reference to the Stage in FlexUnit 4.1 TestCases. I am using the FlexUnit Ant Tasks to generate the TestRunner.mxml file which I have modified to bootstrap the VisualTestEnvironmentBuilder like so:
VisualTestEnvironmentBuilder.getInstance(stage);
However, when FlexUnit tries to run each testcase, I get the following stacktrace:
<testcase classname="com.moshigames.api::TestContentAPIImpl" name="loadFails_completeCallbackCalled" time="5" status="error"><error message="Error #1034: Type Coercion failed: cannot convert org.fluint.uiImpersonation.actionScript::ActionScriptVisualTestEnvironment@5671191 to mx.core.IUIComponent." type="com.moshigames.api::TestContentAPIImpl.loadFails_completeCallbackCalled" ><![CDATA[TypeError: Error #1034: Type Coercion failed: cannot convert org.fluint.uiImpersonation.actionScript::ActionScriptVisualTestEnvironment@5671191 to mx.core.IUIComponent.
at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChild()
at mx.core::Container/addChildAt()
at mx.core::Container/addChild()
at org.fluint.uiImpersonation.actionScript::ActionScriptEnvironmentBuilder/buildVisualTestEn vironment()
at org.fluint.uiImpersonation::VisualTestEnvironmentBuilder/buildVisualTestEnvironment()
at org.flexunit.internals.runners.watcher::FrameWatcher/getStage()
Am I missing something obvious here?
Once possible solution to this problem would be to use a simple ServiceLocator type class for retrieving a stage reference in the Unit Test Cases; Something simple like:
FlexUnitStageLocator.stage;
Which could be bootsrapped as part of the TestCase setup - this would be enourmously beneficial for testing Clients which have to interace with the Stage.
Thanks
jonny.