Question

I am using FlexUnit4 with FlashBuilder4. A lot of the classes that I'm unit testing make use of the Flash Logger.

In the main app, we use TraceTarget so that the logging shows up in the trace window, which greatly aids in debugging:

<!-- route logging to the trace window -->
<mx:TraceTarget includeTime="true"/>

I'd like to do the same thing for the unit test runner that FlashBuilder generates (FlexUnitApplication.mxml), but I'm not sure how to go about it. I could, of course, add TraceTarget to FlexUnitApplication.mxml, but as the warning at the top of the file says,

<!-- This is an auto generated file and is not intended for modification. -->

modifying it probably isn't a good idea.

My question is: how do I get logging-to-trace to work with FlashBuilder and FlexUnit?

Was it helpful?

Solution

I took a cue from the method mentioned in this article and created a UnitTestRunner.mxml that inherits from FlexUnitApplication:

<?xml version="1.0" encoding="utf-8"?>
<local:FlexUnitApplication 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:local="*"                             
                             minWidth="955" minHeight="600">
    <fx:Declarations>
        <!-- send log messages to trace window -->
        <s:TraceTarget includeTime="true"/>
    </fx:Declarations>
</local:FlexUnitApplication>

and then set the Flash Builder settings to run UnitTestRunner instead of FlexUnitApplication (Preferences->Flash Builder->FlexUnit->Custom Application Name).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top