Quick Tip: Correct folder for Unit Tests in Flash Builder 4

I really like the fact that FlexUnit is built right into Flash Builder since one of the main reasons unit testing used to fall off our radars was it was a pain setting up Flex Unit and executing scripts. However one of the things that struck me pretty weird was that Flash Builder was writing tests in the source directory. Best practices in unit testing say that the tests should be in a separate folder called tests/ which should be a sibling of the src/ folder. This lets the tests be written with the same package as the code being tested. This allows, for example, testing functions with a package level visibility.

The correct way to get this working is, when starting the project add another folder called tests for the build path. Now Flash Builder will look at both the source and the tests path when looking for .as files. To write a unit test Test Case, right click on the tests folder and click on the new Test Case option.

New folder for Unit Tests

[Update] I have filed a bug in Adobe’s ticketing system to track this issue. Please vote for it if you agree: http://bugs.adobe.com/jira/browse/FXU-50

Author: Arpit Mathur

Arpit Mathur is a Principal Engineer at Comcast Labs where he is currently working on a variety of topics including Machine Learning, Affective Computing, and Blockchain applications. Arpit has also worked extensively on Android and iOS applications, Virtual Reality apps as well as with web technologies like JavaScript, HTML and Ruby on Rails. He also spent a couple of years in the User Experience team as a Creative Technologist.

4 thoughts on “Quick Tip: Correct folder for Unit Tests in Flash Builder 4”

  1. Great explanation of a best case scenario. I am writing a lot more tests these days, and this tip will help me setup my code better. Thanks.

    Like

  2. “However one of the things that struck me pretty weird was that Flash Builder was writing tests in the source directory”

    This is changable in FB. In wizard which is opened for the testCase class and test Suite class creation user can change the Source Folder and package. (I accept that now for every time creation, it will put the default value). If you prefer to make this configurable, please file an enhancement request in http://bugs.adobe.com/jira under the FlashBuilder – flexunit.

    Like

Leave a Reply to Rani Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: