- 1 What is AsUnit?
- 2 Getting Started
- 3 Tools
- 4 Advanced Usage
- 5 AsUnit tutorials
What is AsUnit?
ASUnit is an ActionScript library that facilitates automated unit testing for ActionScript-based applications, including Flash and Flex applications. The core of ASUnit is a framework of ActionScript classes which can be implemented and subclassed in your application. The ASUnit project also provides tools for implementing the framework, including an MXP extension that runs in the Adobe Flash authoring tool, and a standalone application written in XUL.
Features of the ASUnit framework classes:
- Support for ActionScript 2 (one branch for Flash player 6 and one for players7 and 8) and ActionScript 3
- Framework structure based on the jUnit framework in Java
- Test methods including assertTrue, assertFalse, assertEquals, assertNotNull, assertNotUndefined, assertUndefined, and assertSame
- Support for individual test cases and test suites
- A TestRunner class for (obviously) running your tests
- UI classes for displaying test results, including a text output window with a "success bar" that indicates red for failure, green for pass
Features of the ASUnit Tools XUL application:
- Automated creation of class files targeted at Flash player 6, 7-8, and 9
- Automated creation of test cases
- Automated creation of test suites
- Support for mock objects and asynchronous tests
- Available for Windows, Mac OS X, and Linux
The ASUnit MXP extension is currently deprecated in favor of the XUL application, since many users of ASUnit use other Flash compilers such as MTASC.
At its most basic, AsUnit is simply some ActionScript classes that make it easier for you to build and execute automated tests for your applications. This simple, lightweight component is known as the AsUnit framework, and it currently supports ActionScript 2.0 and ActionScript 3.0 development. The ActionScript 2.0 support has been broken up into 2 packages, one for Flash Player 6 which doesn't support try..catch, and one for Flash Players 7, and 8 which do support try..catch. The latter build is much more similar to JUnit, while the former is more tightly integrated with the Flash Authoring tool.
You will need at least one of the following tools in order to get started with AsUnit. The XUL UI is the quickest path to getting up and running, the Framework is useful for advanced users and the MXP project is being deprecated.
The three builds of the AsUnit Framework can be downloaded and added to any ActionScript project class path.
'Please add general information about the frameworks here, where to get them, how they're organized, some basic info about the Assert class that is common across all builds'
Flash Player 6 (ActionScript 2.0)
'This section should get someone up and running with the as2 framework'
Flash Players 7, 8 (ActionScript 2.5)
'This section should get someone up and running with the as25 framework'
Flash Player 9 (ActionScript Project)
'This section should get someone up and running with the as3 framework, using a pure ActionScript project - try not to talk about FlexBuilder, just MXMLC?'
Flash Player 9 (Flex Project)
'This section should get someone up and running with the as3 framework, using a Flex project - try not to talk too much about Flex Builder, since mac folks are generally not able to use it'
AsUnit comes with some tools to make the creation and management of test cases easier.
The XUL UI is a cross platform tool set that helps with creating and managing ActionScript Classes, Test Cases, and Test Suites. Mac Users need to go through quite a bit more work to get these tools working.
'Please add information here describing how to get and use the XUL UI for Flash Player 6 deployments'
The MXP is a Macromedia Extension that is largely deprecated, doesn't appear to work on OSX and is primarily useful only for Windows developers targeting the Flash 6 Player.
'Please add information here describing how to get and use the MXP extension'
This section should go into more details with regard to creating Asynchronous Test Cases, Asynchronous Test Methods, Visual Test Cases, and other more specific ActionScript testing patterns that come up.