0

我有一个buildspec这样的文件:

version: 0.2


phases:
  install:
    commands:
      - pip install pytest
      - pip install pytest-cov
      - pip install .

  build:
    commands:
      - python -m pytest --junitxml=unittests.xml 

reports:
  unit_tests:
    files:
      - unittests.xml
    file-format: JUNITXML

成功构建,我可以Report groups按预期查看我的报告。

现在我想扩展它并使用选项查看覆盖范围--cov-report。我试过了

version: 0.2


phases:
  install:
    commands:
      - pip install pytest
      - pip install pytest-cov
      - pip install .

  build:
    commands:
      - python -m pytest --junitxml=unittests.xml --cov-report=xml:coverage.xml

reports:
  unit_tests:
    files:
      - unittests.xml
    file-format: JUNITXML
  coverage_tests:
    files:
      - coverage.xml
    file-format: COBERTURAXML

但没有成功。我得到输出:

 generated xml file: /codebuild/output/<removed>/unittests.xml
 ... <skipped a few lines here>
 Report export config is NO_EXPORT, skip exporting reports
 Preparing to copy CODE_COVERAGE report coverage_tests
 Expanding base directory path:  .
 Assembling file list
 Expanding .
 Expanding file paths for base directory .
 Assembling file list
 Expanding coverage.xml
 Skipping invalid file path coverage.xml
 No matching report paths found
 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED
 Phase context status code:  Message: 
 Error in UPLOAD_ARTIFACTS phase: [coverage_tests: [report files not
 found in build]]

如何正确创建报告?

4

1 回答 1

0

正如@TeejayBruno 在评论中指出的那样,我错过了所需的标志。

当我使用(文件的其余部分不变)

- python -m pytest --junitxml=unittests.xml --cov-report=xml --cov=ronwo --cov-branch

一切都按预期工作。

于 2022-01-16T11:52:02.250 回答