title: Flash Builder 4.5 & FlexUnit 4.1
body: <p>We have a large, multi-module product we are writing in Flex 4.1 running on top of a Java-based middle-tier.</p>
  
  <p>Coming from a Java background, I want to have support in our Flex environment for writing and running unit tests.</p>
  
  <p>I've updated Flash Builder 4.5 with the 4.1 release of FlexUnit and I can write and execute unit tests successfully on an application project, but I haven't worked out how to get unit tests working on module or library projects within Flash Builder.</p>
  
  <p><strong>Problems with Library Projects</strong></p>
  
  <p>Since we need the tests compiled to an application (SWF), I either need to create a companion project in Flash Builder or change the linkage type on the library (SWC) project's dependencies to avoid external, since external dependencies are expected to made available by someone else (usually the top-level application).</p>
  
  <p>As an experiment I tried changing the linkage on a sample library project: a test runner SWF was successfully generated, but FlexUnit failed to run it as a #1065 error was reported on something that didn't make any sense to me.</p>
  
  <p>For our headless build (using Gradle), I found this easy to solve by simply merging all dependencies irrespective of their original linkage when generating the test runner SWF. I can also run this easily from within Eclipse using the external tool support as the results are JUnit-compatible XML results that display in the usual JUnit view.</p>
  
  <p><strong>How do you do it?</strong></p>
  
  <p>How do other Flex developers structure their unit tests in a multi-module and multi-library project? Do you run the tests from within Flash Builder 4.5? Can you run tests independently for any library or module project?</p>