I prefer to have my test code separate from my application's code. Just as you mentioned, to have a separate project from the application project. But I have never had that issue, that you mentioned, "...test code couldn't find application classes to test them". In the test project, I would add the application's src folder to its source code. And that's it. Once that test project has reference to those classes, it can instantiated them without a problem.
I like this separation because my application source code doesn't get cluttered with test classes and I am able to automate builds easier with Ant.
Thanks for the reply and that seems like a great idea. I haven't been able to make it work. My application project is Slam and my tests project is SlamTests. I first tried, on SlamTest/src, adding a New Folder --> Advanced --> Link to folder in the filesystem and picking Slam/src. So I ended up with SlamTests/src/src/ having all my application source code linked. But code completion and building doesn't find the files there when I try to type a class name, or an import. I tried refreshing, cleaning, closing and reopening the project, restarting Eclipse. None of that worked.
Next I tried, on SlamTests/src, adding NewFolder --> Advanced --> Link to folder in the filesystem and picking Slam/src/document. So I ended up with SlamTests/src/document/ which seems to make more sense as then the application source code package names will match the file path in SlamTests. But again, code completion and building don't find the linked files.
It's as if the files in a linked folder aren't looked at at all. Which doesn't make sense. So I must be doing something wrong. Anyone have a clue what that might be?
It's as if the files in a linked folder aren't looked at at all. Which doesn't make sense.
That is a very accurate statement when you *link* a folder or file in Eclipse (eg. FlashBuilder). In Eclipse, you can as you already know, link folders into its Workspace. A good reason for this, is to give the developer the ability to open up the linked files thru Eclipse. And hopefully then Eclipse has an editor for that file type. For instance at work, all of my Flex projects are in my Eclipse Workspace (this is typically). But, my project's asset and dependencies files (.xml, .fla, .swf, .swc, .f4v, Flash's asset files .as, etc.) are in a whole separate directory on my file system. So by linking these files, I am able to open them up thru Eclipse, usually its just the .xml files. Also, if you are debugging your Flex application and it loads an external .swf file, by having its src folder linked, you can set-up breakpoints for the Debugger.
But what linking doesnt do is import code into your Flex (test) application when it gets compiled. What you need to do to import code into the Flex application for compilation is the following (I'm recalling these steps from memory, so hopefully its correct):
- in Eclipse, select your project in the 'Project Navigator' panel (typically the panel on the left)
- right-click on the project to bring up a context menu
- in this context menu, select the 'Properties' item to bring up a pop-up
- in this pop-up, select the 'Flex Build Path'
- the right side of this pop-up will update and select the 'Source Path' tab
This is where you can add your applications src code from your test project. And also, the other tab 'Library Path', you can add a .swc file anywhere your computer can access .swc file(s). So by adding your application's src code to the test project this way, you can compile those referenced files in the test runner.
Super, perfect, wonderful! Works just fabulously. Thanks a bunch.