views:

58

answers:

2

I have been trying to get Flex Cover to work correctly for some time but the problem we are encountering is that it only provides code coverage for classes that are currently being hit by our unit tests.

How do we get flex cover to provide correct instrumentation for our entire source directory?

I have tried several different compiler parameters to include all classes with no luck.

Also getting the flex cover fat client to work in a CI environment consistently has never been achieved so we are left to just run Flex Cover manually.

At this point I don't feel like flex cover is mature enough to be used reliably.

Are there any other tools available to get correct code coverage for flex that we should try?

A: 

The next FlexMojos (version 4) will include Flex Test Coverage.

Read more here : http://www.sonatype.com/people/2010/04/flex-test-coverage-kept-simple-with-flexmojos/

PeZ
A: 

FlexMojos isn't quite stable plus we can't upgrade to Maven 3 for various reasons. We ended up just compiling the classes to includes. Below is an example.

<fileset id="test.src.loc.fileset" dir="${test.src.loc}">
    <include name="/Test*.as" />
    <include name="
/*TestCase.as" />
</fileset>

<path id="test.src.loc.path">
    <pathelement location="${test.src.loc}"/>   
</path>

<property name="test.src.loc.path" refid="test.src.loc.path"/>

<pathconvert pathsep="; import " property="test.runner.imports" refid="test.src.loc.fileset">
    <chainedmapper>
        <globmapper from="${test.src.loc.path}\" to=""/>
        <packagemapper from=".as" to=""/>
    </chainedmapper>
</pathconvert>

<pathconvert pathsep=", " property="test.runner.calls" refid="test.src.loc.fileset">     <chainedmapper>
        <globmapper from="${test.src.loc.path}\" to=""/>
        <packagemapper from=".as" to=""/>
    </chainedmapper>
</pathconvert>

<copy tofile="${test.runner}" file="${test.runner.template}" overwrite="true" />

<replace file="${test.runner}" token="#IMPORTS#" value="${test.runner.imports}" /> <replace file="${test.runner}" token="#CALLS#" value="${test.runner.calls}" />

<fileset id="main.src.loc.fileset" dir="${main.src.loc}">
    <include name="com/classes//*.as" />
    <exclude name="com/other/classes/
" />
</fileset>

<path id="main.src.loc.path">
    <pathelement location="${main.src.loc}"/>
</path>

<property name="main.src.loc.path" refid="main.src.loc.path"/>

<pathconvert pathsep=" " property="main.src.loc.classes" refid="main.src.loc.fileset">
    <chainedmapper>
        <globmapper from="${main.src.loc.path}\" to=""/>
        <packagemapper from=".as" to=""/>
    </chainedmapper>
</pathconvert>

<fileset id="library.path" dir="${basedir}">
    <include name="${flexcover.framework.loc}/frameworks/libs/*.swc" />
    <include name="${flexcover.framework.loc}/frameworks/locale/en_US/.swc" />
    <include name="${unit.test.lib.loc}/
.swc" />
    <include name="${lib.loc}/*.swc" />
</fileset>

<pathconvert pathsep=" " property="library.path" refid="library.path"/>

<exec executable="${mxmlc.exe}" dir="${main.src.loc}">
    <arg line="${test.runner}" />
    <arg line="-output ${test.finalName}" />
    <arg line="-source-path ${main.src.loc} ${test.src.loc} ${main.src.loc}/../locale/en_US ${test.src.loc}/../resources" />
    <arg line="-library-path ${library.path}" />
    <arg line="-locale en_US" />
    <arg line="-includes ${main.src.loc.classes}" />
    <arg line="-verbose-stacktraces=true" />
</exec>

Vincen Collins