Flexcover: A Code Coverage Tool for Flex, AIR and AS3

April 12, 2008 on 8:41 am | In Flex, Programming | 11 Comments

I am very pleased to announce the initial experimental release of Flexcover, an open-source code coverage tool suite for Flex, AIR and AS3. The project lives on Google Code at http://code.google.com/p/flexcover/.

Here’s a screenshot:

screen shot of Flexcover

There is so much work left to do on this project, but this release is a start. Rather than wait longer and try to polish it, I felt it was best to get it out there and get some feedback coming in. We’re going to be using it immediately in-house, to be sure — it’s already delivered some valuable news for us on the coverage achieved by our unit test suites!

11 Comments

11 Comments »

RSS feed for comments on this post. TrackBack URI

  1. This is a bug in the command line parsing that occurs when flexcover is installed into a directory with a space in its name. Simply move the flexcover-0.10 folder to a path with no spaces in its name and everything should work fine. There is also a patch posted on the project bug list.

    I will fix this in the next revision, but I’ll probably wait a few days to see what else comes up before putting out 0.11.

    Comment by joe — April 12, 2008 #

  2. Hi Joe,

    Is there any plan for a java Runner?

    I would like to launch it from flex-mojos (My project, who adds flex compilation and tests for flex)

    Any plans for anything like that?

    VELO

    Comment by VELO — April 14, 2008 #

  3. You should be able to launch the CoverageViewer from Java, it’s just an executable that takes command line arguments. Ant is written in Java, and Ant drives all the examples in the project. Use the “-v” switch with Ant to see how it actually invokes the viewer.

    Comment by joe — April 14, 2008 #

  4. Great work, it works very good. I’m having trouble integrating with a large project though. I’m running
    the compiler from the command line and that works well. The problem occurrs when starting the compiled swf since an exception is thrown:
    ReferenceError: Error #1065: Variable coverage is not defined.
    This only happens when the -coverge parameter is set during compilation of the swf. It does however create the metadata file with information but I cant run the app since that exception is thrown. Do you have any clue ?

    Comment by Robert — April 23, 2008 #

  5. Robert — I’m aware of this problem, which occurs when the top level application SWF is either not compiled with -coverage, or it is not a Flex/AIR application.

    There are two workarounds: one is to compile your top-level application SWF with -coverage (assuming it’s a Flex or AIR app). The other way is to include the following snippet somewhere in a class within the SWF that is compiled with -coverage:

    import coverage; coverage;

    I am working on this problem and hope to make this issue disappear in the next relrease.

    Comment by joe — April 23, 2008 #

  6. Found another issue and I’m not sure if this depends on flexCover or flexUnit (we’re using a slight modified version). When running a test suite, only the first test that is executed (which one seems not to be deterministic) sends its results to the coverageViewer. Is this something you’ve seen too ?

    Comment by Robert — April 24, 2008 #

  7. Robert, if you are running an automated test suite that exits when finished, don’t call System.exit() or fscommand(quit). Instead call CoverageManager.exit() at the end of your test suite to first flush out all the accumulated data to the LocalConnection and exit only when that has happened.

    Comment by joe — April 24, 2008 #

  8. Thanks Joe, the flushing now works fine but there is an error just before the coverageManager tries to shutdown the application:

    ReferenceError: Error #1065: Variable NativeApplication is not defined.
    at global/flash.utils::getDefinitionByName()
    at com.allurent.coverage.runtime::CoverageManager$/checkForExit()[C:\work\flex\3.0.x\frameworks\projects\utilities\src\com\allurent\coverage\runtime\CoverageManager.as:203]
    at com.allurent.coverage.runtime::CoverageManager$/handleStatus()[C:\work\flex\3.0.x\frameworks\projects\utilities\src\com\allurent\coverage\runtime\CoverageManager.as:196]

    Comment by Robert — April 24, 2008 #

  9. Well, we don’t call it “experimental” for nothing! This is a bug in the CoverageManager. I’ve logged it as issue #3. As a workaround, you might get hold of the CoverageManager source and stick a try/catch around the line 203 that is causing the problem, then simply compile this source along with your application to override the built-in CoverageManager class.

    That CoverageManager source can be found here:

    http://flexcover-sdk.googlecode.com/svn/trunk/flex3.0.x/frameworks/projects/utilities/src/com/allurent/coverage/runtime/CoverageManager.as

    I’ll fix it in the next release, hopefully out in the next week or two.

    Comment by joe — April 24, 2008 #

  10. […] I actually do with this information? One great example is the new Flex code coverage tool called Flex Cover written by Joe Berkovitz. The tool basically adds functionality to the Flex compiler so that the bytecode it outputs […]

    Pingback by Daniel Dura » Want to Hack on the Flex Compiler? — June 17, 2008 #

  11. […] frameworks they use for test unit coverage in Flex? A quick google search pointed me to this article describing Flexcover, just what I was looking for. Please share your […]

    Pingback by Flex test coverage? — October 10, 2008 #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Entries and comments feeds. Valid XHTML and CSS.
All content copyright (c) 2006-2007 Joseph Berkovitz. All Rights Reserved.