Skip to main content
Participant
December 4, 2008
Question

How to structure tests within a Flex Builder project

  • December 4, 2008
  • 3 replies
  • 1264 views
I am having difficulty in deciding where to store my FlexUnit tests. I am hoping that someone can provide some 'sage advice' for me.<br /><br />The project is simple. Here is the structure:<br /><br />\bin-debug<br />\src\impl\<several AS files><br />\src\unit_tests\\<several AS files><br />\src\main.mxml<br />\src\TestRunner.mxml<br /><br />'impl' is a package where all of my business logic is stored.<br />'unit_tests' are where all of my FlexUnit tests are.<br /><br />With this structure my unit tests cannot import and test any classes within the impl package unless I make the classes public instead of private. I do not want to do this since only 2 of the 10 classes within impl should be exposed by design. The others support those 2 top-level classes.<br /><br />I also want the ability to write unit tests for all of my classes, no matter where they reside. I also want to keep my test code separate from my implementation/production code.<br /><br />Could someone please provide some insight on how I can structure the project so that I have unit tests for all of my classes, which are separate from production code?
This topic has been closed for replies.

3 replies

Participating Frequently
December 5, 2008
Edit the project's properties. Under Flex Build Path, on the Source<br />Path tab, select Add Folder. If you need to share projects between<br />people, it's best to define a Linked Resource. You can find more<br />information on Eclipse Linked resources in the Eclipse help system.<br /><br />-- Daniel R. <danielr@neophi.com> [http://danielr.neophi.com/]<br /><br />On Fri, Dec 5, 2008 at 3:59 PM, Sheldon P <member@adobeforums.com> wrote:<br />> A new message was posted by Sheldon P in<br />><br />> FlexUnit Development --<br />> How to structure tests within a Flex Builder project<br />><br />> Thank-you for your reply Daniel. Your post sheds some light on my problem.<br />><br />> I think the 'source code reference' is my best option. How do I do I create<br />> that reference in Flex Builder?
Participant
December 5, 2008
Thank-you for your reply Daniel. Your post sheds some light on my problem.

I think the 'source code reference' is my best option. How do I do I create that reference in Flex Builder?
Participating Frequently
December 5, 2008
The general approach I've used is to setup a separate project that<br />contains the test code in a parallel package structure. For example:<br /><br />project\<br />project\src\main.mxml<br />project\src\impl\*<br /><br />projectTest\<br />projectTest\src\mainTest.mxml<br />projectTest\src\impl\*Test<br /><br />The Project Test project can then either reference project as a<br />dependent project if it is a library project or use a source code<br />reference if it is an application or a library project. This is mostly<br />a matter of preference depending on how you want your projects to<br />build.<br /><br />The parallel package structure in the test project will let you easily<br />import and test classes in the project under test without having to<br />worry about odd package import issues.<br /><br />-- Daniel R. <danielr@neophi.com> [http://danielr.neophi.com/]<br /><br />On Thu, Dec 4, 2008 at 6:23 PM, Sheldon P <member@adobeforums.com> wrote:<br />> A new discussion was started by Sheldon P in<br />><br />> FlexUnit Development --<br />> How to structure tests within a Flex Builder project<br />><br />> I am having difficulty in deciding where to store my FlexUnit tests. I am<br />> hoping that someone can provide some 'sage advice' for me.