How to run FlexUnit in a continuous build
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…
The same problem (the results are stuck in browser) exists when testing JavaScript code. Lucky for us Adobe Air includes WebKit. This means that the same Air test runner can execute your JavaScript tests as well. Upon the completion of JavaScript tests the test runner can traverse the HTML DOM and collect the JavaScript results and publish them in the same way.
– Enjoy…
From Misko Hevery - The Testability Explorer Blog
As an Agile Coach, Miško is responsible for teaching his co-workers to maintain the highest level of automated testing culture, allowing frequent releases of applications with high quality. He is very involved in Open Source community and an author of several open source projects. Recently his interest in Test Driven Developement turned into http://TestabilityExplorer.org with which he hopes will change the testing culture of the open source community. Misko is a DZone MVB and is not an employee of DZone and has posted 32 posts at DZone.
- Login or register to post comments
- 1368 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)










Comments
yaba replied on Wed, 2009/02/04 - 5:04am
emad964 replied on Sat, 2009/06/27 - 5:58pm