How to customize the FlexUnit4 Application executor

rafanami's Avatar

rafanami

22 Oct, 2013 09:00 PM

Good morning folks.
Is there a way to customize/bypass the generated test application?
Because as I was using FlexMojos, we can customize it via Velocity (the tests fail because there is a "rudimentary parameter injection" going on... I know, FlexUnit4 already have that, but the case here are Legacy Unit Tests...

Thanks in advance, and Kind Regards

Rafa

  1. Support Staff 1 Posted by Yennick Trevels on 23 Oct, 2013 06:23 AM

    Yennick Trevels's Avatar

    At this moment GradleFx doesn't provide a way to customize this.

    What you can do however is using the FlexUnit ant tasks directly, like the GraniteDS team have done. They've put their test code in a separate project so they can use custom compiler options and use the FlexUnit ant task directly.

    Their build script can be found here: https://github.com/graniteds/graniteds/blob/master/build.gradle

    Take a look at the part where they configure the granite-client-flex45-tests project (currently at line 1483).

  2. 2 Posted by rafanami on 23 Oct, 2013 07:35 AM

    rafanami's Avatar

    Hi Yennick, thanks for the quick answer.
    Althought we can try to bypass the gradle build for the test part to execute the ant task directly, it won't accomplish my needs.
    Explaining a little further, the part that generates the TestRunner.mxml for executing the configured testcases is the compilation task from FlexUnit4 ant tasks (using a template in [Compiler.java](https://github.com/rafanami/flexunit/blob/master/FlexUnit4AntTasks/src/org/flexunit/ant/tasks/Compilation.java)).
    So if I change the generateTestRunnerFromTemplate method to get the template from an external source (falling back to the normal template if the externalTestRunnerTemplate property is not set), I can accomplish this (I'll have to change the GradleFX [FlexUnitConvention.groovy](https://github.com/GradleFx/GradleFx/blob/master/src/main/groovy/org/gradlefx/conventions/FlexUnitConvention.groovy) as well, to add this property to the conventions), and change couple of test cases in the meantime... I'll give it a shot tomorrow (GMT +15 here in NZ), and I'll post back a pull request after finishing it up.

    Cheers, Rafa

  3. Support Staff 3 Posted by Yennick Trevels on 23 Oct, 2013 12:00 PM

    Yennick Trevels's Avatar

    Hi Rafa,

    So if I understand it right you just want to use a custom testRunner.xml file.

    What they've done for GraniteDS is create a custom TestRunner.mxml file, and assign this file to the 'mainClass' GradleFx property. So the result of their project will be a swf that executes the tests.
    Then in their FlexUnit ant call, they provide this swf to the 'swf' property of the task, which will then execute the tests by using the swf.

    So all their test code is in a separate project. By doing this they have full control over the TestRunner that is being used and the compiler options that need to be used for the testrunner.

    Greetz

  4. 4 Posted by rafanami on 23 Oct, 2013 07:10 PM

    rafanami's Avatar

    You're right Yennick (not a good idea to read something while half
    asleep)...
    I'll try out this approach of compiling the test part as a separate project.

    Thanks a lot

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