InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Flex, AIR and AS3 Flex Gain Code Coverage Utilities

Posted by Moxie Zhang on May 02, 2008

Sections
Development
Topics
Java ,
Rich Internet Apps
Tags
Flex

Last month Joe Berkovitz of Allurent announced the initial experimental release of Flexcover, an open-source code coverage tool suite for Flex, AIR and AS3.

Java developers who participate in the test-driven development (TDD) process have been using code coverage for some time as a way to measure the extent to which the source code of a program has been tested. However, this capability was not been available for Flex.

Tools used in code coverage for Java include Clover, EMMA, Cobertura and NoUnit. Windows.Net developers have used Ncover, Cover for .Net, and PartCover among others.

To learn more about the experimental release of Flexcover, InfoQ spoke with Berkovitz, who explains:

Flexcover incorporates a modified version of the AS3 compiler, which inserts extra function calls in the code within the SWF or SWC output file. At runtime, these function calls send information on the application's code coverage to a separate tool. The modified compiler also emits a separate coverage metadata file that describes all the possible packages, classes, functions, code blocks and lines in the code as well as the names of the associated source code files.

Recalling the development of Flexcover, Berkovitz says:

I consider testing an essential aspect of software development, and code coverage is a key tool for measuring the quality of one's testing. It answers an important question: "How much of our code is being exercised when we test?"

I have used code coverage tools for other languages with excellent results, but have been frustrated that none was available for Flex. One morning, I woke up and realized that thanks to the Flex compiler becoming open source, it would be possible to modify it in order to add coverage measurement functions to the SWF byte code that it creates. As it turned out, this wasn't too hard to do, as I had worked on compilers and code generators in the past.

According to Berkovitz, the major goals behind the design of Flexcover include:

    • Capturing and viewing coverage information for AS3 applications in real time
    • Making it easy to identify low-coverage areas at a glance
    • Saving out reports of coverage information
    • Viewing saved coverage reports
    • Accumulating coverage data from runs of both automated and manual tests, and
    • Analyzing in term.

In developing Flexcover, Berkovitz carefully built up the existing code coverage tools used for other languages. In particular, he says, “I looked at a number of Java open-source coverage tools, including Emma and Covertura, and the way they presented information. Then, I tried to go one better and add live coverage, so you can watch the source code update with coverage numbers while you test the application.”

Berkovitz explains that the structure of Flexcover consists of three parts:

    1. A set of modifications to the ActionScript compiler, which is written in Java. The result is a modified set of the Java libraries, which support mxmlc and compc, with additional options for code coverage.
    2. A runtime ActionScript library for collecting data in the application under test and writing it out.
    3. An AIR application for reading the data written out by the application under test.

Berkovitz is not alone. Alex Uhlmann of Adobe Consulting has been working on a set of ideas related to code coverage for some time, and he will be collaborating in future releases of Flexcover. Berkovitz and Uhlmann are working together on some new user experience ideas.

When asked about involvement from Adobe, Berkovitz told InfoQ: “I can't comment on anything going on at Adobe, but I know that they are interested in code coverage and that people on the Flex team are actively thinking about how to support it. Also, they've been a big help in getting Flexcover off the ground. I'm grateful for that!”

No comments

Watch Thread Reply

Educational Content

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.

Beauty Is in the Eye of the Beholder

Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.

Architecting Visa for Massive Scale and Continuous Innovation

John Davies examines Visa’s architecture and shows how enterprises have architected complex integrations incorporating Hadoop, memcached, Ruby on Rails, and others to deliver innovative solutions.

Max Protect: Scalability and Caching at ESPN.com

Sean Comerford unveils ESPN.com’s architecture, what components are used and why, and the current changes the website goes through.

The Seven Deadly Sins of Enterprise Agile Adoption

Are there repeated patterns of failure on Enterprise Agile Enablement efforts? Sanjiv and Arlen discuss Seven Deadly Sins to avoid when adopting Agile in an enterprise.

Questions for an Enterprise Architect

Erik Dörnenburg answers: What is Enterprise and Evolutionary Architecture?, discussing 4 issues: Turning strategy into execution, Ensuring conformance, Where do the architects sit? Buying or building?

Wrap Your SQL Head Around Riak MapReduce

Sean Cribbs explains what Map-Reduce and Riak are, why and how to use Map-Reduce with Riak, and how to convert SQL queries into their Map-Reduce equivalents.