Details

Version 0.2.0
Last updated 12th March 2008
Requirements
Demo View demo page
License BSD License
Changelog
0.2.0
  • Fixed: Issue where error thrown when no test results selected.
  • Fixed: Issue where resizing columns could cause the itemRenderer for the status to display horizontal scrollbar.
  • Added: Ability to choose whether to display test results live or wait until all tests complete (as displaying them live results in slower execution of tests, as it's constantly updating the UI) - this is saved as a preference.
  • Added: Ability to toggle display of the class path for the test case - this is saved as a preference.
  • Added: Test result details now extract Expected & Was from message string for failures and display in a manner that is easier to compare.
  • Changed: Test details now displayed on change rather than click event, to allow keyboard navigation of test results.
0.1.0
  • Initial verison

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

  • All features of standard base runner.
  • Uses DataGrid to present test results, allowing clearer overview of tests that have been run & their status, plus ordering by test cases etc.
  • Filter results by different types, all, failures, errors.
  • Instant feedback on test status through use of icons.
  • Instant feedback on reason for failure/error with FlexUnit failure message included inline with the test results.
  • UI gives more room for stack trace, making it easier to read.
  • Only displays stack trace when selected a test.
  • Stack trace highlights lines (in bold) that relate to your test case, helping you quickly zone in on the issue within the stack trace.
  • Added experimental timing of the tests in the results.

Features added in 0.2.0

  • 2 downloads are now available, one compiled to Flex 2.0.1 and the other compiled to Flex 3 as internal changes to Flex mean that the Flex 2.0.1 swc didn't work in Flex 3 projects.
  • Ability to choose whether to display test results live or wait until all tests complete (as displaying them live results in slower execution of tests, as it's constantly updating the UI).
  • Ability to toggle display of the class path for the test case.
  • Test result details now extract Expected & Was from message string for failures and display in a manner that is easier to compare.
  • Preferences (display class path, live results) saved automatically to a shared object.

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:

MXML:
  1. <mx:Application
  2.         ...
  3.         xmlns:defusion="http://www.defusion.org.uk/mxml"
  4.         ... />
  5.        
  6.         <mx:Script>
  7.             <![CDATA[
  8.                 // usual flex unit code to load test cases
  9.             ]]>
  10.         </mx:Script>
  11.        
  12.         <defusion:FlexUnitRunner id="testRunner" width="100%"
  13.             height="100%" />
  14.     </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.

Next Steps

Leave a Tip

If you find this code useful you can leave a donation towards the continued development & support.

Comments are disabled on this post.