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.

Share this:

Like this:

LikeLoading...

Related

Author: Arpit Mathur

Arpit Mathur is a Principal Software Engineer at Comcast Labs where he is currently working on Virtual and Augmented Reality as well as investigating Blockchains and the decentralized internet.
View all posts by Arpit Mathur

“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.