Today I created my first unit tests for Flex code using FlexUnit. Later I integrated the tests with the maven build using Flex Mojos. Flex-Mojos is a collection of maven-plugins created to work with Flex.

We have to use the Flex Compiler Plugin. This plugin is basically used to compile the source files and run tests. This plugin has 5 goals which are bound to different maven lifecycles. I chose to explicitly specify goals that I want maven to run. Maven has a default value for testSourceDirectory as src/test/java. For using Flex mojos, we have to specify testSourceDirectory as src/test/flex. Make sure all your tests are created under this directory.

<goal>test-run</goal> </goals> 

Next thing is to add Flex Unit dependency in the dependency section.


You would also need flash player installed on the build server. In case if you end up with OutOfMemory error, increase the heap size using MAVEN_OPTS in mvn.bat file.


If you need more help, you can always refer the[FlexUnit Example].