带有Circle CI的Codecov覆盖源

时间:2019-09-05 11:15:16

标签: circleci codecov

在我的项目中,我将 circleCI codecov 用于Springboot maven项目。

以下是.circleci / config.yml的相关部分

 # run tests! and gen code coverage
  - run: mvn integration-test cobertura:cobertura

  - store_test_results:
      path: target/surfire-reports

  - run:
      name: Send to CodeCov
      command: bash <(curl -s https://codecov.io/bash)enter code here

maven插件为:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <configuration>
      <formats>
        <format>html</format>
        <format>xml</format>
      </formats>
      <check/>
    </configuration>
  </plugin>

我正在使用默认的codecov.yml,可以在here中找到。

circleci构建成功,但我确实获得了生成的codecov报告,但代码覆盖率仅适用于项目com.x.y.bootstrap bootsrap 包中的文件。

下面是codecov站点中存储库的图像。 enter image description here

寻找的是整个项目的完整代码。

1 个答案:

答案 0 :(得分:0)

我认为问题是由于cobertura-maven-plugin没有选择正确的源类路径;因此会生成包含无效数据的报告。我已将项目更新为使用jacoco-maven-plugin,并使用以下命令运行测试:

  
      
  • 运行:mvn集成测试
  •   

POM文件更改如下:

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.2</version>
    <executions>
      <execution>
        <goals>
          <goal>prepare-agent</goal>
        </goals>
      </execution>
      <execution>
        <id>report</id>
        <phase>test</phase>
        <goals>
          <goal>report</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

那之后的一切都值得。