5 Replies Latest reply on Aug 3, 2010 7:05 AM by legrosb

    ADL.exe doesn't close after unit tests are completed

    sdeschenes17

      I am somewhat new to Flash/Flex/AIR and I apologize if this post is in the wrong location. I have done a lot of research and have yet to find a solution.

       

      I created a simple AIR Test Runner app which performs the simplest unit test (the unit test came from http://docs.flexunit.org/index.php?title=Setting_up_a_FlexUnit_4_Project). I was able to create an Ant build file which compiles my AIR Test Runner app, but when I try to run the unit test, the test completes, but my app remains open. The only way to close it is to click the close button on the window. Now, I created a flash app using the example from http://docs.flexunit.org/index.php?title=Setting_up_a_FlexUnit_4_Project, and when I use Ant to compile and run the tests, Flash Player quickly opens, displays the test results, closes and writes the reports.

       

      Is there something I need to do in my Test Runner.mxml file in order to tell my app (which is being hosted by ADL.exe) to close after the tests finish?

       

      Thanks,

      Scott Deschenes

        • 1. Re: ADL.exe doesn't close after unit tests are completed
          legrosb Level 3

          @Scott - No worries, this is something we could probably document better on the wiki, but it sounds like the missing element may be including the AirCIListener as a listener to the core.  This requires the flexunit-cilistener.swc and the flexunit-aircilistener.swc to be available on the library path during compilation.  The AirCiListner will address closing the ADL window.

           

          There is a collection of examples regarding FlexUnit4 and Ant/Maven/CI located @ http://github.com/flexunit/flexunit/tree/master/FlexUnit4SampleCIProject/.  Check out http://github.com/flexunit/flexunit/blob/master/FlexUnit4SampleCIProject/src/test/flex/Air TestRunner.mxml and http://github.com/flexunit/flexunit/blob/master/FlexUnit4SampleCIProject/build.air.xml for some AIR related examples.  If you run into any further roadblocks, just let us know and we'll work through it.

           

          -Brian

          • 2. Re: ADL.exe doesn't close after unit tests are completed
            sdeschenes17 Level 1

            @Brian - Thank you for your quick response. As a matter of fact, I did include AirCIListener as a listener to the core. And I also made sure to include flexunit-cilistener-4.1.0.swc and flexunit-aircilistener-4.1.0.swc in the library path during compilation.

             

            Here is the code I am using in my .mxml file:

             

            <?xml version="1.0" encoding="utf-8"?>
            <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                                   xmlns:s="library://ns.adobe.com/flex/spark"
                                   xmlns:mx="library://ns.adobe.com/flex/mx"
                                   xmlns:flexUnitUIRunner="http://www.adobe.com/2009/flexUnitUIRunner"
                                   creationComplete="onCreationComplete()">
                <fx:Script>
                    <![CDATA[
                        import com.transparent.SampleAIRProject.SampleSuite;
                       
                        import org.flexunit.listeners.AirCIListener;
                        import org.flexunit.listeners.UIListener;
                        import org.flexunit.runner.FlexUnitCore;
                       
                        private var core:FlexUnitCore;
                        public function onCreationComplete():void
                        {
                            core = new FlexUnitCore();
                            core.addListener(new UIListener (uiListener));
                            core.addListener(new AirCIListener());
                            core.run(SampleSuite);
                        }
                    ]]>
                </fx:Script>
                <flexUnitUIRunner:TestRunnerBase id="uiListener" width="100%" height="100%"/>
            </s:WindowedApplication>

             

            I am also including the code from my Ant file that compiles the app and executes the tests for my app:

             

            <exec os="Windows XP,Windows Server 2008"
                        executable="java"
                        dir="${basedir}"
                        failonerror="true">
                       
                 <arg line="-Xmx384m -Dsun.io.useCanonCaches=false"/>
                 <arg line="-Dapplication.home=${flex.sdk.home}"/>
                 <arg line="-jar ${flex.sdk.home}/lib/mxmlc.jar"/>
                 <arg line="+configname=air"/>
                 <arg line="${release.arg}"/>
                 <arg line="-static-link-runtime-shared-libraries=true"/>
                 <arg line="+flexlib=${flex.sdk.home}/frameworks"/>
                 <arg line="-library-path+=${flexunit.library.path}"/>
                 <arg line="-source-path+=${src.dir}"/>
                 <arg line="-output=${test.output.dir}/${testswf.name}"/>
                 <arg line="-file-specs=${src.dir}/${project.name}.mxml"/>

            </exec>

            <copy file="${test.dir}/${project.name}TestRunner-app.xml" todir="${test.output.dir}" overwrite="true"/>
            <replace
                 file="${test.output.dir}/${project.name}TestRunner-app.xml"
                 token="[This value will be overwritten by Flash Builder in the output app.xml]"
                 value="${project.name}TestRunner.swf"/>

             

            <exec
                 os="Windows XP,Windows Server 2008"
                 executable="${flex.sdk.home}/bin/adl.exe"
                 failonerror="false"
                 resultproperty="test.result">
                       
                 <arg line='"${test.output.dir}/${project.name}TestRunner-app.xml"'/>
                 <arg line="-- '${test.report.dir}'"/>

            </exec>
                   
            <junitreport todir="${test.report.dir}">
                 <fileset dir="${test.report.dir}">
                      <include name="TEST-*.xml"/>
                 </fileset>
                 <report format="frames" todir="${test.report.dir}/html"/>
            </junitreport>

             

            I am aware of the examples you provided and have been using them as a guide for helping to determine my problem. The odd thing is I was able to create a flash app using the example on the wiki and my flash app works just fine when I build it using Ant. Is it possible I am compiling my AIR app incorrectly, based on the Ant code I provided?

             

            Thanks,

            Scott

            • 3. Re: ADL.exe doesn't close after unit tests are completed
              legrosb Level 3

              @Scott - The test runner application looks good as well as the compilation, at a glance.  The only thing that pops out at me is that your Ant script doesn't seem to use the flexunit Ant task, but rather launch ADL directly.  Ideally, you should use the flexunit Ant task launch ADL; the Ant task is what generates the AIR descriptor and informs ADL to close, amongst other things.  For example:

               

               

              <flexunit player="air"
                 swf="<path to your test SWF>"
                 toDir="${report.loc}"
                 haltonfailure="false"
                 verbose="true" />

               

               

              Running ADL directly won't result in ADL closing because nothing is managing the ADL process.  If this is a typo, just send along the corrected Ant script, otherwise, I believe that may be your issue.  Let me know how it goes.

               

              -Brian

              • 4. Re: ADL.exe doesn't close after unit tests are completed
                sdeschenes17 Level 1

                @Brian - Using the flexunit Ant task solved my problem. Strange though, one of my colleagues created an AIR application and he launches ADL directly. But he might be using an earlier version of the Flex SDK and FlexUnit.

                 

                Thanks for the help.

                 

                Scott Deschenes

                • 5. Re: ADL.exe doesn't close after unit tests are completed
                  legrosb Level 3

                  @Scott - Weird.  Yeah unless you choose to manage the process in your build script (i.e. - track pid and kill it after completion), it should hang regardless the version of the Ant task you're using.  Glad to hear this is working for you now though.  Thanks for the feedback.

                   

                  -Brian