4 Replies Latest reply on Aug 6, 2010 10:44 AM by aberfield

    ant tests: undefined method runWithFlexUnit4Runner?

    aberfield Level 1

      Hi all!


      I am trying to automate AIR tests that run successfully via Adobe Flash Builder 4.

      I get the following error:

        Error: Call to a possibly undefined method runWithFlexUnit4Runner through a reference with static type flexunit.flexui:FlexUnitTestRunnerUI.


          [mxmlc]                 testRunner.runWithFlexUnit4Runner(currentRunTestSuite(), "unit_tests");

      when I run the tests from command line via: ant -v clean package.


      The part of the build.xml responsible for this is:


      <target name="test" depends="compile">

      <!-- Execute FlexUnit tests and publish reports -->








                 <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>

                 <source-path path-element="${FLEX_HOME}/frameworks"/>

                 <compiler.source-path path-element="${test.src.loc}"/>

                 <compiler.include-libraries dir="${lib.loc}" append="true">

                  <include name="pb3dlib.swc" />


                  <include name="airframework.swc" />

                  <include name="airglobal.swc" />

                  <include name="airspark.swc" />

                  <include name="applicationupdater_ui3.swc" />

                  <include name="automation_airspark.swc" />

                  <include name="automation_spark.swc" />

                  <include name="flexunit_0.9.swc" />

                  <include name="flexunit-aircilistener-4.1.0.swc" />

                  <include name="flexunit-cilistener-4.1.0.swc" />

                  <include name="flexunit-core-flex-" />

                  <include name="flexunit-core-flex-4.1.0.swc" />

                  <include name="flexunit-uilistener-4.1.0.swc" />

                  <include name="flexunitextended.swc" />

                  <include name="hamcrest-1.0.2.swc" />

                  <include name="spark.swc" />

                  <include name="utilities.swc" />

                  <include name="flexunit.swc" />

                  <include name="FlexUnitOptional.swc" />

                  <include name="FlexUnitTestRunner_rb.swc" />



      What swc do I need to include?




        • 1. Re: ant tests: undefined method runWithFlexUnit4Runner?
          mlabriola Level 4



          You appear to be using the code generated by Flash Builder Wizards. That will work *only* inside of Flash Builder and not via an ant task as it tries to open a socket back to Flash Builder. That code is written and maintained by Adobe, not the FlexUnit team.


          When you say you are trying to automate this, do you mean you are trying to use it with a CI system or just build and run it from ant?


          Let me know and we can provide direction,


          • 2. Re: ant tests: undefined method runWithFlexUnit4Runner?
            aberfield Level 1

            Hi Mike!


            My goal is to be able to build and run an AS component and associated tests both via Flash Builder 4 and via an automation. I can modify the tests if I find a better way to achieve my goal (I don't have to use runWithFlexUnit4Runner if you have a better suggestion).

            I want to be able to build and run tests with ant. Right now I am modifying the FlexUnit4SampleCIProject, just because it is the example linked from the Flex Unit page. I copied the component under src/main and tests under src/test.  

            Out of curiosity, is there a way to automate the code generated by Flash Builder Wizards?


            • 3. Re: ant tests: undefined method runWithFlexUnit4Runner?
              mlabriola Level 4



              The actual tests created by Flash Builder are fine, it is really just the main application file they create. They don't ship the source, so modifying it is difficult.


              You can, however do something like this example:


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



                    creationComplete="runMe()" >





                  import compilationSuite.SuitesToRun;


                  import org.flexunit.listeners.CIListener;

                  import org.flexunit.runner.FlexUnitCore;

                  import org.flexunit.runner.notification.async.XMLListener;



                  private var core:FlexUnitCore;



                  public function runMe():void {

                      core = new FlexUnitCore();

                      //Put this line in if you want to write the XML to disk for use in reporting or a CI server

                      core.addListener(new CIListener());



                      //Leaving this one in allows you to see the results in Flash Builder as well if it is open

                      //Else, it will just fail and go on. The name in the quotes below is your project name

                      core.addListener(new XMLListener("unit_tests"));


                      //Finally, pass what you want to run to the core.run() method. This could be the result of your currentRunTestSuite() from the

                      //previous code you pasted

                      core.run( compilationSuite.SuitesToRun );





              • 4. Re: ant tests: undefined method runWithFlexUnit4Runner?
                aberfield Level 1

                Hi Mike!


                Modifying the MXML file solved my test compile errors for command line, thank you very much!