3 Replies Latest reply on Jun 13, 2010 5:22 PM by mlabriola

    Issues with adding FlexUnitTestRunnerUI to FlexUnitCore

    abeymg Level 1

      Hi

       

      I am trying to create a test runner app with both a CIListenter and a UIListener. For the UIListener I am trying to use the FlexUnitTestRunnerUI, however when I try to use it as shown in the SampleCIProject I get the following compilation error:

       

       

      Description Resource Path Location Type

      1067: Implicit coercion of a value of type flexunit.flexui:FlexUnitTestRunnerUI to an unrelated type org.flexunit.runner.notification:IRunListener. ConsumerTests.mxml /PlayerDesktopTests/src line 30 Flex Problem

      Looks like an API change somewhere. Any ideas?
      Thx
      - abey
      =============================================
      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark"
         xmlns:mx="library://ns.adobe.com/flex/mx"
         minWidth="955"
         minHeight="600"
         xmlns:flexui="flexunit.flexui.*"
         creationComplete="onCreationComplete()">
      <fx:Script>
      <![CDATA[
      import modelTestSuite.ModelTestSuite;
      import org.flexunit.listeners.CIListener;
      import org.flexunit.listeners.UIListener;
      import org.flexunit.runner.FlexUnitCore;
      public function currentRunTestSuite():Array
      {
      var testsToRun:Array=new Array();
      testsToRun.push(modelTestSuite.ModelTestSuite);
      return testsToRun;
      }
      private function onCreationComplete():void
      {
      var core:FlexUnitCore=new FlexUnitCore();
      core.addListener(new CIListener());
      core.addListener(new UIListener(testRunner));
      core.run(currentRunTestSuite());
      }
      ]]>
      </fx:Script>
      <flexui:FlexUnitTestRunnerUI id="testRunner"/>
      </s:Application>
        • 1. Re: Issues with adding FlexUnitTestRunnerUI to FlexUnitCore
          mlabriola Level 4

          That won't work.You are trying to use the FlexUnit1 TestRunnerUI directly as a listener in FlexUnit 4.

           

          A version of that old runner has been adapted to work with FlexUnit 4, but it is a different class altogether.

           

          I think this is what you are looking for. Note the differences in namespace and class.

           

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application

          xmlns:mx="http://www.adobe.com/2006/mxml"

          creationComplete="runMe()" xmlns:adobe="http://www.adobe.com/2009/flexUnitUIRunner">

           

          <mx:Script>

          <![CDATA[

          import org.flexunit.listeners.UIListener;

          import compilationSuite.SuitesToRun;

           

          import org.flexunit.listeners.CIListener;

          import org.flexunit.runner.FlexUnitCore;

           

          private var core:FlexUnitCore;

           

           

          public function runMe():void {

            core = new FlexUnitCore();

            core.addListener( new CIListener() );

            core.addListener( uiListener ); //(You also shouldn't need that extra layer of wrapping the TestRunnerBase in a UIListener first)

            core.run( compilationSuite.SuitesToRun );

          }

          ]]>

          </mx:Script>

          <adobe:TestRunnerBase id="uiListener" width="100%" height="100%"  />

          </mx:Application>

           

          HTH,

          Mike

          • 2. Re: Issues with adding FlexUnitTestRunnerUI to FlexUnitCore
            abeymg Level 1

            Thanks for the reply. I assumed FlexUnitTestRunnerUI was the new FlexUnit4 test runner because, that's what FB4 automagically created.

            In any case, looks like FlexUnitTestRunnerUI automatically registers as a listener to FlexUnitCore, because I was able to achieve my objective by using the following:

             

            <?xml version="1.0" encoding="utf-8"?>

             

            <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

               xmlns:s="library://ns.adobe.com/flex/spark"

               xmlns:mx="library://ns.adobe.com/flex/mx"

               minWidth="955"

               minHeight="600"

               xmlns:flexui="flexunit.flexui.*"

               creationComplete="onCreationComplete()">

            <fx:Script>

            <![CDATA[

            import modelTestSuite.ModelTestSuite;

             

            import org.flexunit.listeners.CIListener;

            import org.flexunit.listeners.UIListener;

            import org.flexunit.runner.FlexUnitCore;

             

            public function currentRunTestSuite():Array

            {

            var testsToRun:Array=new Array();

            testsToRun.push(modelTestSuite.ModelTestSuite);

            return testsToRun;

            }

             

             

            private function onCreationComplete():void

            {

            var core:FlexUnitCore=new FlexUnitCore();

            core.addListener(new CIListener());

             

            core.run(currentRunTestSuite());

            }

            ]]>

            </fx:Script>

             

            <flexui:FlexUnitTestRunnerUI id="testRunner"/>

             

            </s:Application>

            • 3. Re: Issues with adding FlexUnitTestRunnerUI to FlexUnitCore
              mlabriola Level 4

              i am sorry. i misread your code from my phone the first time. the class adobe includes is a bit weird. it isnmt really a runner or a listener. it instantiates a core and a listener internal to the class, but doesnt expose either.. making it a pain.

               

              i am trying to get adobe to change that

               

              as an fyi, if you took the code i provided and add an xmllistener to the core, it would also push the restults back to builder. in the end, adobes class, is their ui, an instantiation of the core, and the xmllistener composed

               

              mike