Skip to end of metadata
Go to start of metadata

FlexUnit was donated but has yet to be formulated into a release.

Meanwhile you can find a nightly build at https://builds.apache.org/job/flex-flexunit/ws/ (flexunit-*.zip).

Installing the project

FlexUnit 4 Distribution

FlexUnit 4 is distributed in three ways. First, it is available as a turnkey download, which will allow you to get up and running immediately and try out the new features. Second, it is available as a compiled SWC file, which is an ActionScript library. Finally, you can download and use
the source directly.

All the relevant SWC files needed are included in Adobe Flash Builder 4 Premium by default, allowing you to unit test your applications without the need to specifically download/install any of the above files.

Turnkey Installation

You can get a copy of the FlexUnit 4 turnkey project via our downloads page on flexunit.org. The turnkey project contains a compiled version of the FlexUnit 4 library, FlexUnit .9 library (for any legacy tests), a graphical test runner example that will execute your tests in a browser, and a compiled version of the Hamcrest library . This version is geared toward Flex developers who are interested in exploring how FlexUnit 4 works, without spending time to set up or configure a project.

In the turnkey installation project you will find several TestSuites:

  • FlexUnit4Suite, which demonstrates and tests basic FlexUnit4 functionality.
  • The HamcrestSuite, which demonstrates and tests the use of Hamcrest in FlexUnit4.
  • The FlexUnitIn360 suite, which corresponds to the overview of FlexUnit 4 testing provided in this tutorial post .

We recommend that users new to FlexUnit 4 download the turnkey project and review the FlexUnitIn360 suite.

Library Installation

FlexUnit 4 is also available as a library project directly without the surrounding turnkey project. You can download the latest stable library versions with ASDocs and needed artifacts from the download page at flexunit.org. You can download specific version builds and nightly build versions from our automated build system at https://builds.apache.org.

FlexUnit 4 is compatible with ActionScript 3, Flex 2, Flex 3 and Flex 4 projects. You can get the version needed for your specific purpose along with the ASDocs and needed artifacts from the download page at flexunit.org, or you can download specific version builds and nightly build versions from our automated build system at https://builds.apache.org. After obtaining the correct file, extract it and simply drop the FlexUnit4.swc into the libs directory of your project and you are ready to use it.

FlexUnit 4 vs. FlexUnit .9

Both the Turnkey project and Flash Builder include both FlexUnit 4 and FlexUnit .9 to allow developers who created unit tests in .9 to continue using those tests. You may notice when you are importing some function definitions that you have the choice of flexunit.framework or org.flexunit. flexunit.framework is the package used in the older FlexUnit .9, so disregard it if you do not need to support legacy tests. Instead, use org.flexunit.

You may notice code completion for functions such as assertObjectEquals, assertMatch, assertNoMatch, assertContained, assertNotContained, assertUndefined, and assertNotUndefined. These are legacy functions supported in FlexUnit .9 that have since been superseded by Hamcrest matching.

You may choose to remove FlexUnit1Lib.swc from your project bin folder or project references to avoid any confusion.

If you are using ActionScript 3 Only:

Be sure you are using an ActionScript 3 build of FlexUnit 4. By default, FlexUnit includes code to work with Flex UIComponents. Further, the Flex version has the ability to work with Fluint, which is a Flex-only integration testing framework. As such, attempting to use a Flex version in ActionScript project will result in linker errors when the FlexUnit 4 framework code cannot find requisite classes.

Some errors you might receive when using a FlexUnit4.swc file built for Flex in an ActionScript project include:

  • Type was not found or was a compile-time constant: mx.core:IMXMLObject.
  • Type was not found or was a compile-time constant: mx.rpc:IResponder.
  • Type was not found or was a compile-time constant: ArrayCollection.
  • Type was not found or was a compile-time constant: ChangeWatcher.
  • Type was not found or was a compile-time constant: ICollectionView.
  • Type was not found or was a compile-time constant: ILogger.
  • Type was not found or was a compile-time constant: ILoggingTarget.
  • Type was not found or was a compile-time constant: Sort.

If you are using Flex 4

If you are using Flash Builder 4 with Flex 4, there is nothing to do. By default FlexUnit 4 is included with Flash Builder 4 (Premium only, not in Standard edition). If you are not using Flash Builder, then just follow the directions for Flex 3.

If you are using Flex 3

Create a new Flex project and copy the <font size=2>FlexUnit4.swc</font> file into the libs folder of that Flex project.

If you are using Flex 2:

Create a new Flex project. Create a folder named libs in that project and copy the <font size=2>FlexUnit4.swc</font> file into the new folder.

Next, you will need to add this folder to your build path. Do this by:

  • Project properties->Flex Build Path.
  • Click the Library Path Tab.
  • Click the Add SWC Folder button.
  • Browse to the libs folder and click OK.
  • Click OK on the properties panel to close it.

This new Flex project, created with either the source code or the SWC library, will hold your tests and your test runner. Unfortunately, in Flex 2, the way metadata was preserved for a project was not as user friendly. So, you will also need to add parameters to the compiler arguments of your project:

  • Project properties->Flex Compiler.
  • Update your additional compiler arguments to add the following items to whatever arguments are already present
    -keep-as3-metadata=RunWith,BeforeClass,AfterClass,Before,After,Suite,Test,TestCase,Ignore,Filter,Sort,Theory,DataPoint,DataPoints,ArrayElementType
    -define=CONFIG::useFlexClasses,true
  • Click OK on the properties panel to close it.

Previous | Next

  • No labels

1 Comment

  1. The link to the turnkey project appears broken, as does the library link.