0

我们正在使用 Android Annotations、Cobertura 和 maven。Cobertura 正在引入 _ 类以进行单元测试覆盖。我们如何排除它们?

我尝试将以下内容添加到我的 pom 中,但它只工作了一半。类不再显示在报告中,但当该包中基类的覆盖率为 100% 时,该包的行和分支覆盖率显示 <5%。

<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>

我在命令行生成覆盖率报告:

mvn clean test -Ucobertura:cobertura

我们也使用 Jenkins,但我现在只对本地报告感兴趣。一旦这些工作正常,我将在我们的构建服务器上对其进行测试,并在需要时招募一些本地专家。

如果不可能,如何添加 _ 类的源文件夹,以便至少可以单击查看孔在哪里?

4

0 回答 0