I'm using cobertura with Maven to generate code coverage reports. We'd like to be able to fail the build when not enough code is covered by test cases. Based on the maven-cobertura-plugin's web page for "check", I configured my pom file like this:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<check>
<branchRate>85</branchRate>
<lineRate>85</lineRate>
<haltOnFailure>true</haltOnFailure>
<totalBranchRate>85</totalBranchRate>
<totalLineRate>85</totalLineRate>
<packageLineRate>85</packageLineRate>
<packageBranchRate>85</packageBranchRate>
</check>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</reporting>
When I execute maven, I get this error:
The parameters 'check' for goal org.codehaus.mojo:cobertura-maven-plugin:2.6:check are missing or invalid
I tried running in debug mode and I see this in the output for check
:
[INFO] --- cobertura-maven-plugin:2.6:check (default-cli) @ MyApplication --- [DEBUG] Configuring mojo org.codehaus.mojo:cobertura-maven-plugin:2.6:check from plugin realm ClassRealm[plugin>org.codehaus.mojo:cobertura-maven-plugin:2.6, parent: sun.misc.Launcher$AppClassLoader@9b6d0342] [DEBUG] Configuring mojo 'org.codehaus.mojo:cobertura-maven-plugin:2.6:check' with basic configurator --> [DEBUG] (f) dataFile = G:\dev\MyApplication\target\cobertura\cobertura.ser [DEBUG] (f) forceMojoExecution = false [DEBUG] (f) maxmem = 64m [DEBUG] (f) mojoExecution = org.codehaus.mojo:cobertura-maven-plugin:2.6:check {execution: default-cli} [DEBUG] (f) pluginClasspathList = [org.codehaus.mojo:cobertura-maven-plugin:maven-plugin:2.6:, net.sourceforge.cobertura:cobertura:jar:2.0.3:compile, org.ow2.asm:asm:jar:4.1:compile, org.ow2.asm:asm-tree:jar:4.1:compile, org.ow2.asm:asm-commons:jar:4.1:compile, org.ow2.asm:asm-util:jar:4.1:compile, org.ow2.asm:asm-analysis:jar:4.1:compile, oro:oro:jar:2.0.8:compile, jaxen:jaxen:jar:1.1-beta-8:compile, dom4j:dom4j:jar:1.6.1:compile, jdom:jdom:jar:1.0:compile, xerces:xmlParserAPIs:jar:2.6.2:compile, xerces:xercesImpl:jar:2.6.2:compile, xom:xom:jar:1.0b3:compile, com.ibm.icu:icu4j:jar:2.6.1:compile, xalan:xalan:jar:2.6.0:compile, org.ccil.cowan.tagsoup:tagsoup:jar:0.9.7:compile, org.apache.ant:ant:jar:1.8.3:compile, org.apache.ant:ant-launcher:jar:1.8.3:compile, org.mortbay.jetty:servlet-api-2.5:jar:6.1.14:compile, org.mortbay.jetty:jetty:jar:6.1.14:compile, org.mortbay.jetty:jetty-util:jar:6.1.14:compile, com.sun:tools:jar:0:system, log4j:log4j:jar:1.2.9:compile, net.sourceforge.cobertura:cobertura-runtime:pom:2.0.3:compile, urbanophile:java-getopt:jar:1.0.9:compile, commons-cli:commons-cli:jar:1.0:compile, org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-4:compile, org.apache.maven.reporting:maven-reporting-api:jar:2.0.8:compile, org.apache.maven.doxia:doxia-sink-api:jar:1.0-alpha-9:compile, org.apache.maven.reporting:maven-reporting-impl:jar:2.0.4.2:compile, commons-validator:commons-validator:jar:1.2.0:compile, commons-beanutils:commons-beanutils:jar:1.7.0:compile, commons-digester:commons-digester:jar:1.6:compile, commons-logging:commons-logging:jar:1.0.4:compile, xml-apis:xml-apis:jar:1.0.b2:compile, org.apache.maven.doxia:doxia-core:jar:1.0:compile, org.apache.maven.doxia:doxia-site-renderer:jar:1.0:compile, org.codehaus.plexus:plexus-i18n:jar:1.0-beta-7:compile, org.codehaus.plexus:plexus-velocity:jar:1.1.7:compile, org.apache.velocity:velocity:jar:1.5:compile, org.apache.maven.doxia:doxia-decoration-model:jar:1.0:compile, commons-collections:commons-collections:jar:3.2:compile, org.apache.maven.doxia:doxia-module-apt:jar:1.0:compile, org.apache.maven.doxia:doxia-module-fml:jar:1.0:compile, org.apache.maven.doxia:doxia-module-xdoc:jar:1.0:compile, org.apache.maven.doxia:doxia-module-xhtml:jar:1.0:compile, commons-lang:commons-lang:jar:2.4:compile, org.codehaus.plexus:plexus-utils:jar:2.0.2:compile, org.apache.maven.shared:maven-invoker:jar:2.0.11:compile] [DEBUG] (f) project = MavenProject: com.mycompany:MyApplication1.0.0 @ G:\dev\MyApplication\pom.xml [DEBUG] (f) quiet = false [DEBUG] (f) skip = false [DEBUG] -- end configuration --
I don't see anything that's obviously wrong, so I'm not sure why I can't run check
.
I'm running the embeded version of Maven from RAD 8.5, using a run configuration with this goal:
clean cobertura:check
If I run the build as
clean cobertura:cobertura
the check process doesn't run and the build succeeds, even though I know I have less than 85% coverage.
Does anyone know what's wrong with cobertura:check
and how I can get it working?
It seems the correct way to do what I want is to call Maven with the goals: clean verify site
.