3 Replies Latest reply on Apr 12, 2013 7:38 AM by Omererer

    All async unit tests timeout

    Omererer Level 1

      I am trying to run FlexUnit tests through Ant in a very simplified version of the sampleCLIProject. The tests pass when I compile through Flash Builder and timeout when I run them through Ant on Windows. This timeout problem only occurs in the case of async tests. When I run them through Ant on Mac OS X, Ant is unable to receive data back from Flash Player.

       

      Here's the main application that runs the tests:

       

      TestRunner.mxml

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                                              xmlns:flexUnitUIRunner="http://www.adobe.com/2009/flexUnitUIRunner"
                                              layout="absolute"
                                              creationComplete="runTests();">
       <mx:Script>
                          <![CDATA[
                                    import org.flexunit.demo.EchoPanelTest;
                                    import org.flexunit.listeners.CIListener;
                                    import org.flexunit.listeners.UIListener;
                                    import org.flexunit.runner.FlexUnitCore;
        
                                    public function runTests() : void {
                                              var core : FlexUnitCore = new FlexUnitCore();
                                              core.addListener(new UIListener(uiListener));
                                              core.addListener(new CIListener());
        
                                              core.run(EchoPanelTest);
                                    }
                          ]]>
       </mx:Script>
       <flexUnitUIRunner:TestRunnerBase id="uiListener" width="100%" height="100%"/>
      </mx:Application>
      

       

      Here's the Ant build file:

       

      build.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <project name="Main Build File"
               default="run">
      
       <property file="build.properties" />
      
       <taskdef resource="flexTasks.tasks"
                         classpath="${TASK_DIR}/flexTasks.jar" />
      
       <taskdef resource="flexUnitTasks.tasks">
        <classpath>
        <fileset dir="/Users/ohassan/Downloads/flexunit 2">
        <include name="flexUnitTasks*.jar" />
        </fileset>
        </classpath>
       </taskdef>
      
       <target name="compile">
        <mxmlc file="${SRC_DIR}/TestRunner.mxml"
                                 output="${BIN_DIR}/Main.swf">
        <library-path dir="${LIB_DIR}"
                                                  append="true">
        <include name="*.swc" />
        </library-path>
        <compiler.verbose-stacktraces>true</compiler.verbose-stacktraces>
        <compiler.headless-server>true</compiler.headless-server>
        </mxmlc>
       </target>
      
       <target name="run"
                        depends="compile">
        <flexunit swf="${BIN_DIR}/Main.swf"
                                    timeout="5000"
                                    toDir="${basedir}/reports"
                                    haltonfailure="false"
                                    verbose="true"
                                    localTrusted="false"
                                    command="${FLASH_PLAYER}" />
       </target>
      </project>
      

        • 1. Re: All async unit tests timeout
          mlabriola Level 4

          Please clarify.

           

          If you can regular (non-asynchronous) tests through the ant task everything works fine... however, if you run asynchronous tests through the ant task it fails?

           

          To be honest, everyone I have ever helped with this problem has eventually found that a firewall or some other issue on their local machine was blocking the connection between the flash player and the java code that runs from the ant script. That is why I am asking for confirmation on whether all tests fail through ant or you literally mean only asynchronous tests fail in ant.

           

          We are running a setup identical to yours here on our build server without issue and many of the authors of the flexunit code you are using were on mac os x. I am happy to try to help.

           

          Mike

          • 2. Re: All async unit tests timeout
            Omererer Level 1

            Thanks, Mike, for your reply. On Windows, Ant can communicate with Flash Player, so let's leave Mac aside for now and see what may be causing the timeout on Windows.

            If you can regular (non-asynchronous) tests through the ant task everything works fine... however, if you run asynchronous tests through the ant task it fails?

            Yes, on Windows, Ant runs all tests. Asynchronous ones fail with the message "Timeout Occurred before expected event" and others pass. But it's not all asynchronous tests that fail -- just the UI ones that use UIImpersonator.addChild(). Please see my post on this discussion: http://forums.adobe.com/message/5229030#5229030

             

            Thanks again!