I'm working on a general code library for ActionScript 3.0 called as3lib
which includes several extensions to the core API and some useful functions. I've written several unit tests (using FlexUnit) to make sure everything is working correctly.
What is the best way to organize these tests in the library? Currently, I have all my code in src/
and my tests in test/
but I've set up a secondary Flex project to run the unit tests. I am also manually adding and removing the test files from the library when I want to run the tests.
What I'm doing doesn't seem right. Is there a better way? Preferably one where the compiled library doesn't include the test files but I don't need two separate projects to test them.
The way we've done these things at my company is that we actually include both under the source directory, and then we have two application mxml files which we use. One is the testing suite, which includes all of the appropriate links to unit-test classes, the other is the main application. We have also have two package structures inside of the src folder: one package structure com.., and another tests.com... Make sure that ALL source code for unit tests are ALWAYS in the tests package -- this way you can use only one SVN ignore, and you can also make sure that your tests do not create dependent and hard-coded relationships with other projects.
There are two ways which we use to ensure that the test.com source files are not included. The automated build system only references the main application, and since that only imports from com., mxmlc.exe will only include the files for the main application. When building locally, inside of eclipse, you can control how things build by clicking on the little arrow next to Debug and scroll to "Organize favorites." When you click "Add", you should be able to select all root level .mxml files which reference the Application class. Be sure to add the base application and the new unit test application file. When you then click "OK", the arrow now allows you to debug either as the main application, or your unit test framework.
As an aside, we also use FlexUnit as our testing framework. I like it.