Skip to main content
Participant
August 5, 2010
Answered

ant tests: undefined method runWithFlexUnit4Runner?

  • August 5, 2010
  • 1 reply
  • 3213 views

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]

    [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 -->

         <mxmlc

            file="${test.src.loc}/FlexUnitApplication.mxml"

            output="${bin.loc}/FlexUnitApplication.swf"

            actionscript-file-encoding="UTF-8"

            keep-generated-actionscript="true"

            incremental="false"

        >

           <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-4.0.0.2-sdk3.5.0.12683.swc" />

            <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" />

           </compiler.include-libraries>

        </mxmlc>

What swc do I need to include?

Thanks,

--Andreea

This topic has been closed for replies.
Correct answer mlabriola

Andreea,

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"?>

<mx:Application

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

      creationComplete="runMe()" >

<mx:Script>

  <![CDATA[

    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 );

}

]]>

</mx:Script>

</mx:Application>

1 reply

Participating Frequently
August 5, 2010

Andreea,

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,

Mike

aberfieldAuthor
Participant
August 5, 2010

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?

Thanks,
--Andreea

mlabriolaCorrect answer
Participating Frequently
August 5, 2010

Andreea,

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"?>

<mx:Application

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

      creationComplete="runMe()" >

<mx:Script>

  <![CDATA[

    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 );

}

]]>

</mx:Script>

</mx:Application>