0

We're using Android Annotations, Cobertura, and maven. Cobertura is pulling in the _ classes for unit test coverage. How can we exclude them?

I tried adding the following to my pom but it only worked halfway. The classes no longer show in the report but line and branch coverage for that package shows <5% when the coverage for the base classes in that package are at 100%.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.hps.prosper.android</groupId>
    <artifactId>TabletCore</artifactId>
    <version>0.2.0-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>Prosper-TabletCore</name>

    <properties>
        <stomp.version>0.2.0-SNAPSHOT</stomp.version>
        <java.version>1.6</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit-dep</artifactId>
            <version>4.10</version>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.pivotallabs</groupId>
            <artifactId>robolectric</artifactId>
            <version>1.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.googlecode.androidannotations</groupId>
            <artifactId>androidannotations</artifactId>
            <version>2.7.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.googlecode.androidannotations</groupId>
            <artifactId>androidannotations-api</artifactId>
            <version>2.7.1</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>src</sourceDirectory>
        <testSourceDirectory>test</testSourceDirectory>
        <resources>
            <!-- filter manifest and put filtered file in target/filtered-manifest/ -->
            <resource>
                <directory>${project.basedir}</directory>
                <targetPath>${project.build.directory}</targetPath>
                <includes>
                    <include>AndroidManifest.xml</include>
                    <include>res/**/*</include>
                </includes>
            </resource>
        </resources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>cobertura-maven-plugin</artifactId>
                    <version>2.5.2</version>
                    <configuration>
                        <instrumentation>
                            <ignores>
                                <ignore>com.hps.prosper.android.tabletcore.library.entity.*</ignore>
                                <ignore>com.hps.prosper.android.tabletcore</ignore>
                                <ignore>com.hps.prosper.android.contexts.*</ignore>                             </ignores>
                            <excludes>
                                <exclude>com/hps/prosper/android/tabletcore/library/entity/**/*.class</exclude>
                                <ignore>com/hps/prosper/android/tabletcore/*.class</ignore>
                            </excludes>
                        </instrumentation>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>clean</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.5.0</version>
                    <extensions>true</extensions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.2</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <run>
                        <debug>true</debug>
                    </run>
                    <sdk>
                        <platform>12</platform>
                    </sdk>
                    <emulator>
                        <avd>16</avd>
                    </emulator>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.2</version>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

I'm generating coverage reports at the command line:

mvn clean test -Ucobertura:cobertura

We also use Jenkins, but I'm just interested in the local reports for now. Once those are working right I'll test it on our build server and enlist some local gurus if needed.

If it's not possible, how can I add the source folder for the _ classes so I can at least click through and see where the holes are?

5
  • If I was to attempt to answer your question I would need a bit more context. For instance, it'd be nice to see more of your pom of how you run cobertura to see if that is correct
    – Blundell
    Jul 12, 2013 at 21:08
  • Edited to show more of the pom and how I'm generating coverage reports. Jul 12, 2013 at 21:20
  • Ah I was getting mixed up, we don't use the includes for cobertura, but for checkstyle. Don't know sorry. You can take a look through our pom for a comparison anyway: github.com/novoda/public-mvn-repo/blob/master/poms/reporting/…
    – Blundell
    Jul 12, 2013 at 22:23
  • Little confused on what are that _classes? Secondly you should bump up your dependencies. Android maven plugin is 3.6.0 and also coberture and others are newer versions too
    – peter_budo
    Jul 12, 2013 at 23:05
  • Android annotations is a library that adds a lot of nice annotations for android. It works by creating subclasses of the annotated class. These classes are name <base-class>_.java. I want to avoid seeing the generated classes in my code coverage reports. Jul 14, 2013 at 17:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.