如何从Jacoco报道中排除一个类?

问题描述 投票:1回答:1

我想以某种方式使用Jacoco,以便从整体报道中排除Sample.java class。为了达到这个目的,我在qvenxswpoi目标中包含了<exclude>,这是maven pom.xml中的目标

Jacoco插件:

prepare-agent

Surefire插件:

                <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.1.201405082137</version>
            <executions>
                <execution>
                    <id>default-prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

属性部分:

            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.4.3</version>
            <configuration>
                <excludes>
                    <exclude>**/*Sample.java</exclude>
                </excludes>
            </configuration>
        </plugin>
maven jenkins jacoco cobertura jacoco-maven-plugin
1个回答
0
投票

这是为JaCoCo配置排除/包含的正确方法:

    <properties>
    <argLine>-Dfile.encoding=ISO-8859-1</argLine>
</properties>

有关更多详细信息,您可以浏览此文档: <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.7.1.201405082137</version> <executions> <execution> <id>default-prepare-agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> </executions> <configuration> <excludes> <exclude>**/*Sample.java</exclude> </excludes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.4.3</version> </plugin> </plugins>

© www.soinside.com 2019 - 2024. All rights reserved.