Test coverage support

Skip to end of metadata
Go to start of metadata

If you take testing seriously as I do, you most likely know test code coverage tools. And on Flex Universe the de facto standard and unique alternative is Flex Cover.  But let's be honest here, the tool does the job, but isn't simple. Requiring a special compiler made me dislike the idea of running code coverage on Flex projects. And mainly that was why test code coverage never got into Flexmojos. The available tool was too complex to use, making it so complicated to automate that I never gave it any serious thought.

Since day ZERO, Flexmojos has as master goal to KISS (Keep It Simple Stupid Smartguy).  With that in mind, Flexmojos is proud to announce a state of art test code coverage support.

Flexmojos test code coverage support is really, really easy to use. Just need to set coverage to true.http://repository.sonatype.org/content/sites/flexmojos-site/4.0-SNAPSHOT/test-compile-mojo.html#coverage

How does it work

Flexmojos is using Apparat. Apparat is a framework to optimize ABC, SWC and SWF files.

Better than that, Apparat allows people to manipulate actionscript bytecode. So this was the way to go. Instrument flex test code w/o a custom compiler. So I start to talk to Joa Ebert, Apparat author. He made changes on apparat side to make possible to instrument the Flexmojos test runner SWF and I made the changes to Flexmojos to collect the code usage flag by Apparat.

Once the code usage information is collected Flexmojos uses Cobertura to handle that information and to genarate reports. This allows Flexmojos to generate html, xml and/or summaryXml. http://repository.sonatype.org/content/sites/flexmojos-site/4.0-SNAPSHOT/test-run-mojo.html#coverageReportFormat

This is only available on Flexmojos 4. So if you never thought about Maven 3... that may be the time.

Note: Only reports line coverage, not branch coverage.

Sample project

To show how simple it is to enable test code coverage on Flexmojos 4.x, we will edit Flexunit sample project to enable code coverage. The project can be found here. Once you get the sources, edit pom.xml. There are just 2 simple changes:

  1. change the %flexmojos.version property to 4.0-SNAPSHOT;
  2. add <coverage>true</coverage> to flexmojos configuration section;

The pom with all required changes is available here.

Running $mvn clean install will produce the following report:

The original report can be found here

Configuration Options

test-compile goal options: https://repository.sonatype.org/content/sites/flexmojos-site/4.0-SNAPSHOT/test-run-mojo.html
test-run goal options http://repository.sonatype.org/content/sites/flexmojos-site/4.0-SNAPSHOT/test-compile-mojo.html

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jun 05, 2010

    Olivier Chicha says:

    This is exactly what I was looking for, it's working great. Two little things :...

    This is exactly what I was looking for, it's working great.

    Two little things :

    - I think there is a bug on interfaces, the package declaration of interfaces is marked as a non tested line

    - I could only access your pom by replacing "https" by "http" : http://svn.sonatype.org/flexmojos/branches/flexmojos-4.x/flexmojos-touchstone/coverage/

    1. Jun 06, 2010

      Marvin Herman Froeder says:

      Https things fixed. No clue on package

      Https things fixed.

      No clue on package