7 Replies Latest reply: Oct 21, 2009 12:29 PM by legrosb RSS

    Help with flex4unit ant build.xml: Socket timeout waiting for flexunit report

    timoxley Community Member

      I'm having trouble setting up ant to build and test my project locally and I'm not sure what the next step is.



      • Running on XP/Cygwin.
      • All of the files that FlexUnit4 references when used in Flash Builder are in my '${basename}/libs' folder (eg FlexUnit4_1.0.swc).
      • I've placed the flexunit4 task in my ant/libs folder.


      I'm getting two errors...


      I don't think I've set up the 'socket' stuff right for the tests. It just sits and waits then dies...


       [flexunit] Waiting for client connection ...
       (about a minute later)
       [flexunit] Stopping server ...
       [flexunit] End of test data reached, sending acknowledgement to player ...
       [flexunit] Closing client connection ...
       [flexunit] Closing server on port [1024] ...
      java.util.concurrent.ExecutionException: Socket timeout waiting for flexunit report


      Plus this is the error I get from the flash player:


      ReferenceError: Error #1065: Variable mx.skins.spark::BorderSkin is not defined.


      I don't know why it's complaining about Borderskin as I think I have included all the flex4 libs I could find. I suspect this second error is causing the first error?



      Any help appreciated. I think I'm just setting it up all wrong.


      Screencap of errors:





        • 1. Re: Help with flex4unit ant build.xml: Socket timeout waiting for flexunit report
          legrosb Community Member

          @timoxley - Try changing your test runner to compile linking in the Flex libraries rather than externalizing them.  The Ant task is goint to try and execute your SWF outright rather loading it at runtime as a module, so your SWF needs to have everything its depends on linked into it; the Error #1065 is an error from the FP that a class definition is missing (from what I could tell).  I think the following change may help:


          <mxmlc file="${SRC_FOLDER}/FlexUnitApplication.mxml" keep-generated-actionscript="false" output="${OUTPUT_FOLDER}/${ant.project.name}Tests.swf">
                       <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
                       <source-path path-element="${FLEX_HOME}/frameworks"/>
                       <compiler.library-path dir="${FLEX_HOME}" append="true">
                           <include name="frameworks/libs" />
                       <compiler.library-path dir="${basedir}" append="true">
                           <include name="libs" />

          If that doesn't work out, then check your test runner code to make sure it's adding the CIListener class to the core before the test suite(s) is being executed.  Hope this helps.

          • 2. Re: Help with flex4unit ant build.xml: Socket timeout waiting for flexunit report
            timoxley Community Member

            Thanks Brian. Issue possibly related to not know what i was doing a few hours ago, also problems due using a different version of the library than in the examples.

            • 3. Re: Help with flex4unit ant build.xml: Socket timeout waiting for flexunit report
              timoxley Community Member

              Finally got everything working using the files from the CI Example which what i probably should have done in the first place.


              So a rough guide for anyone just starting out with this:


              Download the Flex 4 'workspace' from the digital primates hudson server . This appears to contain flexunit library and examples in various stages of development.


              I used Flex Builder 4 Beta 2 to set up my Test Suite and Test Cases.


              I then loaded the libs folder from:




              into my flex project's libs folder:


              this includes:

              • FlexUnit4.swc
              • FlexUnit4CIListener.swc
              • flexUnit4UIRunner.swc
              • flexTasks.jar
              • flexUnitTasks.jar


              I didn't need to remove the FlexUnit4 stuff that is 'referenced' automatically by flash builder when you start adding flexunit4 tests/suites.


              Then I used a modified version of the TestRunner.mxml found in:





              The lines to pay attention to are the ones that look like:


              static public function currentRunTestSuite():Array {
                  var testsToRun:Array = new Array();
                  return testsToRun;

              Just make sure you update this list to include all of the test suites &/or individual tests you want to run.


              I made this a static function and modified the code in the "FlexUnitApplication.mxml" file to use this function so i'd only need to update one list of suites/tests.


              FlexUnitApplication.mxml is generated automatically when you run FlexUnit4 tests in the Flash Builder 4 Beta 2 IDE.



              This is the build.xml file I'm using in the project:




              Change the name of the project from "Flare" to whatever and adjust the other path settings where required (though you might want to write this from scratch at least once so you understand roughly what is going on).


              The Debug Flash Player must be installed on the server otherwise you'll get a:


              java.util.concurrent.ExecutionException: Socket timeout waiting for flexunit report


              ...while it waits for the non-existant debugger to attach. (This is obvious but I did forget and was a bit bewildered for a moment)


              Need to also ensure the environment variable:FLEX_HOME is set to the location you installed the flex sdk...by editing your .bashrc setting the environment variable the in the Hudson Configuration.


              You'll need to point Hudson at your ant installation and your jdk installation. If you downloaded he sdk, be aware you might need to point it to the jdk folder inside the place you installed the sdk.


              And I think that's all the problems I had. Hope it's useful to someone... if anyone who actually knows what they are doing can point out any potential issues/better ways of doing things, feel free to comment.


              Thanks to Brian (legrosb) and Mike (mlabriola) for their assistance!

              • 4. Re: Help with flex4unit ant build.xml: Socket timeout waiting for flexunit report
                legrosb Community Member

                @timoxley - Couple notes to add:


                - You can use the release stand-alone or debug stand-alone Flash Player to use the FlexUnit4 Ant task.  The key to getting the Flash Player to run is associating the SWF mimetype (application/x-shockwave-flash) with the stand-alone Flash Player executable (if you're running on Mac or Windows) in your OS.  On Windows we use rundll32 to launch the associated player for the SWF mimetype and on the Mac we use the "open" command.  On Linux, you need to make sure a symlink for the flashplayer executable you want to use is created with a name of "gflashplayer" and is available on the user's path.  These are all reminents of the FU1 Ant task, so if needed we can refactor this out for a more standardized approach if people would like.


                - If you would not like to setup an evironment variable for FLEX_HOME, based on the build script you've provided, you can pass the following argument to Ant:  -Denv.FLEX_HOME=/full/path/to/your/SDK


                Hopefully we'll have the Flex 4 build fixed in the coming months so people can d/l a zip like they can for the other SDK versions; the only project giving us trouble with the build is the UIRunner project.


                Thanks for putting the work into an example using the current environment, hopefully we can make it easier going forward.



                • 5. Re: Help with flex4unit ant build.xml: Socket timeout waiting for flexunit report
                  timoxley Community Member

                  Thanks Brian.


                  It was all fairly easy once I knew what was going on, but as I had no experience with any unit testing or continuous integration before it was all fairly unfamiliar. Hope it helps someone.





                  • 6. Re: Help with flex4unit ant build.xml: Socket timeout waiting for flexunit report
                    trevorbutler Community Member



                    I have also ran into the issue with "java.util.concurrent.ExecutionException: Socket timeout waiting for flexunit report".  In my case, I had a Flex project with FlexUnit 4 tests and an ant script to drive the compile, testing, reporting, etc. All of this was running successfully with the latest FlexUnit 4 from SVN on my Windows XP desktop machine.  I moved the entire project over to a Windows Server 2003 machine to test there, and have been running into the socket timeout when the <flexunit> ant task tries to launch the flash player.


                    Brian, your comment about "associating the SWF mimetype (application/x-shockwave-flash) with the stand-alone Flash Player executable" is perhaps the key to what causes the trouble.  The Windows Server OS did not have flash installed, so I opted to install the debug flash player that was embedded in the FlashSDK3.4 that I am using (I used the debug player on my desktop machine also).  On my desktop machine, I can browse the TestRunner.SWF file that the compile produces and see that it is of type "Shockwave Flash Object".  But on the server machine, there is no such association. 


                    The question is: why did the flash player installer not create the association on Windows Server? I think I had the non-debug version of flash installed on my desktop, and I uninstalled that prior to switching to the debug player there, so that is why I did not notice any issues on my desktop.


                    I fixed the problem on Windows Server by manually trying to open the SWF and telling Windows to use the player executable under the FlexSDK3.4.  Now I can get successful launches of the player with the <flexunit> task.


                    But someone might want to look into the debug player install...




                    • 7. Re: Help with flex4unit ant build.xml: Socket timeout waiting for flexunit report
                      legrosb Community Member

                      @trevorbutler - Good question for the FP team, I'm not really sure of the answer.  To clarify though, you don't need the debug FP to use the FU4 Ant task.  You do need the standalone player, but there is a release player that comes in standalone/projector form.   I will make sure the README.txt in the sample project make a note of this behavior on Windows to help prevent others from running into this.  Thanks for the help.