【发布时间】:2017-02-15 09:13:24
【问题描述】:
到目前为止,我根据它们的包名或类名来排除某些类。有什么方法可以将下面给出的枚举排除在覆盖范围之外?
package com.*;
public enum Quality {
high,normal,low;
}
对于 Coverage,我将 maven-surefire-plugin 与 JUnit 和 JMockit 一起使用。我的覆盖设置如下所示
<build>
<plugins>
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>
<configuration>
<systemPropertyVariables>
<coverage-excludes>com.test.*,*IT.java</coverage-excludes>
</systemPropertyVariables>
</configuration>
</plugin>
....
</build>
<dependencies>
....
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit-coverage</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
....
</dependencies>
【问题讨论】:
-
为什么要排除枚举?当然,如果您的某些生产代码使用这些枚举,它们将被覆盖,否则它会指示您未使用某个值。
标签: java maven junit jmockit maven-surefire-plugin