About

The FlexUnit Custom Test Runner is a customised FlexUnit test runner which aims to improve the presentation and ease of use of running FlexUnit tests. I have used unit testing in a few different languages, so obviously when I started using Flex I wanted to start off on the right foot by using unit testing from the outset.

However after a couple of days using the base runner which is provided with FlexUnit I found myself spending a lot more time than I thought I should just looking for the details of the problem in the flex runner. I think that the base runner is not conducive to quickly finding the cause of test failure(s), I believe it is due to the following reasons:

  1. The test failure/error message is not presented against the failed test.
  2. Trying to read the stack trace is made difficult due to it being in a narrow column (lots of scrolling is required, especially when testing deep component packages).

Features

Screen shot of FlexUnit Runner in action

Features added in 0.2.0

Usage

Once the FlexUnitRunner.swc is added to your library path for the Flex compiler usage is as simple as replacing any instances of the <flexunit:TestRunnerBase .../> component in your test runners.

Example:

<mx:Application
  ...
  xmlns:defusion="http://www.defusion.org.uk/mxml"
  ... />

  <mx:Script>
    <![CDATA[
      // usual flex unit code to load test cases
    ]]>
  </mx:Script>

  <defusion:FlexUnitRunner id="testRunner" width="100%"
    height="100%" />
</mx:Application>

Demo

There is a demo for the FlexUnit Runner which has a test case which has tests that produce the different scenarios found in FlexUnit tests: success, failure, error, to provide an example of how the FlexUnit Runner handles these scenarios.

A note on the test timing

I have added some timing around the running of each of the tests within the runner, these times are then displayed in the results. I’ve had a poke around the source code for FlexUnit but find it quite difficult to follow through running a TestCase (as it bounces around all over the place within the code - thankfully I’m not the only person to have problems trying to follow the code). So I’m not 100% sure on the accuracy of the timing I am attempting. For example, I’m not sure if the code I’m testing includes the calls to the setUp and tearDown methods - which if it does these will be included in the timing.