So you have a flash or Flex code with lots of unit-tests. That is great, but how do you get them running in a continuous build? Sure you can run the tests manually, but this only gives you a visual green or red bar, what you really want is a X-Unit XML file so that you can run the test in an automated fashion and display or email the result to everyone on your team. The problem is that flash runs in a sandbox and as a result the FlexUnit is not allow to tell anyone about the success or failure of any test, which makes publishing the results kind of hard.
Enter Adobe Air to the rescue! Adobe Air is a flash player, which is outside of the sandbox. As a result Adobe Air application can write to local file system. And because Adobe Air is flash it is 100% compatible with your flash / Flex code which you are trying to test. Here is what you need:
- Adobe Air SDK (here)
- FlexUnit (here)
- Your code with tests
- An example code how to hook everything together (flextestrunner-71b586ca6655)
Basic idea is straight forward. Use an ant script to compile your ActionScript code together with unit tests into an Air executable. The executable runs the tests with special XMLListener which records the tests into X-Unit complaint XML file and writes it out to the filesystem. The Air application than quits with status code which equals to the number of test failures. The continuous build can than use the status code and the XML report to publish the test results.
For extra points…