【问题标题】:cobertura:check seems to be missing parameterscobertura:check 似乎缺少参数
【发布时间】:2014-09-08 22:45:03
【问题描述】:

我正在使用 cobertura 和 Maven 来生成代码覆盖率报告。当测试用例没有覆盖足够的代码时,我们希望能够使构建失败。基于 maven-cobertura-plugin 的 web page for "check",我将我的 pom 文件配置如下:

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

当我执行 maven 时,我得到这个错误:

目标 org.codehaus.mojo:cobertura-maven-plugin:2.6:check 的参数“检查”丢失或无效

我尝试在调试模式下运行,我在check 的输出中看到了这一点:

[信息] --- cobertura-maven-plugin:2.6:check (default-cli) @ MyApplication --- [调试] 配置 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] [调试] 使用基本配置器配置 mojo 'org.codehaus.mojo:cobertura-maven-plugin:2.6:check' --> [调试] (f) 数据文件 = G:\dev\MyApplication\target\cobertura\cobertura.ser [调试] (f) forceMojoExecution = false [调试] (f) maxmem = 64m [调试] (f) mojoExecution = org.codehaus.mojo:cobertura-maven-plugin:2.6:check {execution: default-cli} [调试] (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.cobert ura: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:common s-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:编译,org.codehaus.plexus:plexus-utils:jar:2.0.2:compile, org.apache.maven.shared:maven-invoker:jar:2.0.11:compile] [调试] (f) 项目 = MavenProject: com.mycompany:MyApplication1.0.0 @G:\dev\MyApplication\pom.xml [调试] (f) 安静 = 假 [调试] (f) 跳过 = 假 [DEBUG] -- 结束配置 --

我没有看到任何明显错误的地方,所以我不确定为什么我不能运行 check

我正在使用 RAD 8.5 的嵌入式版本的 Maven,使用具有此目标的运行配置:

清洁cobertura:检查

如果我将构建运行为

干净的 cobertura:cobertura

尽管我知道我的覆盖率低于 85%,但检查过程没有运行并且构建成功。

有谁知道cobertura:check 有什么问题以及如何让它工作?

【问题讨论】:

    标签: maven cobertura maven-cobertura-plugin


    【解决方案1】:

    似乎做我想做的事情的正确方法是用目标调用 Maven:clean verify site

    【讨论】:

      【解决方案2】:

      在插件标签内的 pom.xml 中使用下面

      <plugin>
                      <groupId>org.codehaus.mojo</groupId>
                      <artifactId>cobertura-maven-plugin</artifactId>
                      <version>2.6</version>
                      <configuration>
                          <formats>
                              <format>html</format>
                              <format>xml</format>
                          </formats>
                      </configuration>
                      <executions>
                          <execution>
                              <phase>package</phase>
                              <goals>
                                  <goal>cobertura</goal>
                              </goals>
                          </execution>
                      </executions>
                  </plugin>
      

      并在 pom.xml 的项目标签中使用下面。

      <reporting>
              <plugins>
                  <plugin>
                      <groupId>org.codehaus.mojo</groupId>
                      <artifactId>cobertura-maven-plugin</artifactId>
                      <version>2.6</version>
                  </plugin>
              </plugins>
          </reporting>
      

      这对我有用

      【讨论】:

        猜你喜欢
        • 2019-11-24
        • 1970-01-01
        • 1970-01-01
        • 2017-01-03
        • 2017-03-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-04-29
        相关资源
        最近更新 更多