English 中文(简体)
班级的伊格诺雷方法。 cobertura maven plugin
原标题:Ignore methods in class. cobertura maven plugin

I have maven 3, cobertura maven plugin 2.51 and some classe. I need to know test coverage of my class. But I don t want to test setters/getters. So I wand just to ignore them.

 <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <formats>
                        <format>html</format>
                        <format>xml</format>
                    </formats>
                    <check>
                        <haltOnFailure>false</haltOnFailure>
                        <lineRate>55</lineRate>
                        <branchRate>60</branchRate>
                        <packageLineRate>60</packageLineRate>
                        <packageBranchRate>60</packageBranchRate>
                        <totalLineRate>60</totalLineRate>
                        <totalBranchRate>60</totalBranchRate>
                    </check>
                    <instrumentation>
                        <excludes>
                            <exclude>com/FileCopier*.*</exclude>
                            <exclude>com/FileCopierWithCamel*.*</exclude>
                            <exclude>com/Main*.*</exclude>
                        </excludes>
                    </instrumentation>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>clean</goal>
                            <goal>cobertura</goal>
                            <goal>check</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
            </plugin>

接着,我又说,在被忽略的情况下,我 block倒了。

 <ignores>
                            <!-- Ignore all setter and getter methods in your classes -->
                            <ignore>com.*.set*</ignore>
                            <ignore>com.*.get*</ignore>
                            <ignore>com.MyClass.getName</ignore>
                        </ignores>

但似乎与工作不一样。

I found this link: http://jira.codehaus.org/browse/MCOBERTURA-52 Looks like this problem is about 5 year old. Is there any solution of my problem?

问题回答

如果仅涉及采集器和设计器,你可以制定<条码>。 Trivalchange:

Cobertura Changelog - New --ignoreTrivial switch that tells Cobertura to ignore the following in the coverage report: Getter methods that simply read a class field; Setter methods that set a class field; Constructors that only set class fields and call a super class constructor.

资料来源:)。

如果你想更具体地忽略方法,你也可以使用<条码>。 方法:

Cobertura Changelog - New --ignoreMethodAnnotation switch used to specify an annotation that, when present on a method, will cause Cobertura to ignore the method in the coverage report.

文件:/code>,但随后使用。 覆盖面

<代码>pom.xml中的例:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>cobertura-maven-plugin</artifactId>
  <version>2.7</version>
  <configuration>
    <instrumentation>
      <ignoreTrivial>true</ignoreTrivial>
      <ignoreMethodAnnotation>foo.bar.CoberturaIgnore</ignoreMethodAnnotation>
    </instrumentation>
  </configuration>
</plugin>

我们正在使用Cbertura语进行春季-博伊特的安普朗斯测试标准。

我们的情况类似。 为了忽视单位测试代码覆盖度指标中的一些班级,这些班级有秘密的本地问询,不能与JPA测试班(如记忆银行)一起测试。

pom.xml

<build>
        <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <formats>
                        <format>html</format>
                        <format>xml</format>
                    </formats>
                    <instrumentation>
                        <ignoreTrivial>true</ignoreTrivial>
                        <ignoreMethodAnnotation>com.thermofisher.micro.common.annotation.CoberturaIgnore</ignoreMethodAnnotation>           
                    </instrumentation>
                </configuration>
                <executions>
                  <execution>
                    <goals>
                      <goal>clean</goal>
                    </goals>
                  </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <reporting>
      <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <formats>
                        <format>html</format>
                        <format>xml</format>
                    </formats>
                    <instrumentation>
                        <ignoreTrivial>true</ignoreTrivial>
                        <ignoreMethodAnnotation>com.thermofisher.micro.common.annotation.CoberturaIgnore</ignoreMethodAnnotation>           
                    </instrumentation>
                </configuration>
            </plugin>
       </plugins>
    </reporting>

<><>Annotation

package com.any.package.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Documented
@Target({ElementType.METHOD, ElementType.TYPE, ElementType.PACKAGE})
public @interface CoberturaIgnore {}

www.un.org/Depts/DGACM/index_spanish.htm 使用通知:

package com.any.package.repository;

import com.any.package.annotation.CoberturaIgnore;

@CoberturaIgnore
@Repository
public class SequenceIdRespositoryImpl implements SequenceIdRespository {

    @PersistenceContext
    private EntityManager entityManager;


    @CoberturaIgnore
    @Override
    public long getUserContactKey() {
        Query query = entityManager.createNativeQuery("select user_key_seq.nextval from dual");
        return getKey(query);
    }
}   




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签