UnitTest compilation fails when using type='mobile'

plank.michael's Avatar

plank.michael

05 Jan, 2014 03:03 PM

I'm trying to run unit tests in my mobile air project.
As a test, I've duplicated the flexunit-single-project example project and changed the type to 'mobile' and added:

flexUnit {
command = "${flexHome}/bin/adl" player = "air" ...

I get the following exception:

test main class file: /Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/build/reports/FlexUnitRunner.mxml
Compiling with mxmlc
+configname=airmobile -source-path+=/Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/src/main/actionscript -source-path+=/Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/src/test/actionscript -incremental=true -output=/Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/build/reports/TestRunner.swf /Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/build/reports/FlexUnitRunner.mxml -library-path+=/Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/libs/flexunit-4.1.0-8-flex_4.1.0.16076.swc -library-path+=/Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/libs/flexunit-cilistener-4.1.0-8-4.1.0.16076.swc -library-path+=/Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/libs/flexunit-uilistener-4.1.0-8-4.1.0.16076.swc -library-path+=/Users/crow/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-as3/1.1/87773cab5ece2719d208df07497884a040dd12c3/hamcrest-as3-1.1.swc [ant:java] Java Result: 1 :test FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':test'.

    java.lang.Exception: mxmlc execution failed: Loading configuration file /Users/crow/Documents/Development/AS_Development/Flex_SDKs/flex_sdk_4.9.1_AIR_3.7/frameworks/airmobile-config.xml Failed to match the compile target with /Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/build/reports/TestRunner.swf.cache. The cache file will not be reused. /Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/build/reports/FlexUnitRunner.mxml(43): Error: 'TestRunnerBase' declaration must be contained within the tag, since it is not assignable to the default property's type 'Array' or element type 'mx.core.IVisualElement'.

When changing the type back to 'swc or 'air' everything works.
Does this problem somehow relate to the airmobile-config.xml?

Thanks,
Michael

  1. Support Staff 1 Posted by Yennick Trevels on 05 Jan, 2014 03:27 PM

    Yennick Trevels's Avatar

    It may indeed have something to do with the airmobile-config.xml and how mobile applications are configured. It's trying to compile the flexUnit test application with the mobile configuration, which won't work since the mobile Application class behaves differently compared to its desktop equivalent.

    Maybe you can override this 'configname' property by using the flexUnit.additionalCompilerOptions property.

  2. 2 Posted by plank.michael on 05 Jan, 2014 06:53 PM

    plank.michael's Avatar

    Alright, I'm trying to do so, but somehow, the flexUnit.additionalCompilerOptions does not have any effect on the compilation.

    flexUnit {
    command = "${flexHome}/bin/adl" player = "air" verbose = true additionalCompilerOptions = ['-incremental=false', '-output=/Users/crow'] }

    I still get:

    test main class file: /Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/build/reports/FlexUnitRunner.mxml
    Compiling with mxmlc
    +configname=airmobile -source-path+=/Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/src/main/actionscript -source-path+=/Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/src/test/actionscript -incremental=true -output=/Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/build/reports/TestRunner.swf /Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/build/reports/FlexUnitRunner.mxml -library-path+=/Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/libs/flexunit-4.1.0-8-flex_4.1.0.16076.swc -library-path+=/Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/libs/flexunit-cilistener-4.1.0-8-4.1.0.16076.swc -library-path+=/Users/crow/Documents/Development/Gradle/GradleFx-Examples-master/flexunit-air-single-project/libs/flexunit-uilistener-4.1.0-8-4.1.0.16076.swc -library-path+=/Users/crow/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-as3/1.1/87773cab5ece2719d208df07497884a040dd12c3/hamcrest-as3-1.1.swc

    What am I doing wrong?

  3. Support Staff 3 Posted by Maxime Cowez on 05 Jan, 2014 07:15 PM

    Maxime Cowez's Avatar

    You didn't override the configName flag; in the output it still says: configname=airmobile.

    Try adding configname=air to the additionalCompilerOptions.

  4. 4 Posted by plank.michael on 05 Jan, 2014 08:03 PM

    plank.michael's Avatar

    Sorry for the confusion, I actually had a different problem...

    Anyway, I got the unit tests with the air mobile project working now with:

    flexUnit {
    command = "${flexHome}/bin/adl" player = "air" verbose = true additionalCompilerOptions = [ '+configname=air' ] }

    Thanks a lot for your help Maxime and Yennick

  5. 5 Posted by plank.michael on 05 Jan, 2014 09:21 PM

    plank.michael's Avatar

    Since I now had the exact same problem when using the latest Flex SDK 4.11, I figured out how to solve the problem, without overriding the configname property.

    The test runner classes seem to require the mx.swc, which is not included in the compiler configs of the airmobile-config.xml of the Flex SDK 4.9.1 and also not included in the compiler configs of Flex SDK 4.11.

    So what I did to get it working is adding the mx.swc to the dependencies:

    test group: 'org.hamcrest', name: 'hamcrest-as3', version: hamcrest_as3_version, ext: 'swc'
    test files(project.file('lib/flexUnitTasks-4.1.0-8.jar').absolutePath,
    project.file('lib/flexunit-4.1.0-8-flex_4.1.0.16076.swc').absolutePath, project.file('lib/flexunit-cilistener-4.1.0-8-4.1.0.16076.swc').absolutePath, project.file('lib/flexunit-uilistener-4.1.0-8-4.1.0.16076.swc').absolutePath) test files("${flexHome}/frameworks/libs/mx/mx.swc")

    There is no need for the flexUnit.additionalCompilerOptions = ['+configname=air'] anymore.
    Now everything seems to work so far :-)

  6. Support Staff 6 Posted by Yennick Trevels on 05 Jan, 2014 09:23 PM

    Yennick Trevels's Avatar

    Cool! I'll have a look whether this can be fixed in GradleFx itself.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac