【问题标题】:AWS CodeBuild Test Report Is EmptyAWS CodeBuild 测试报告为空
【发布时间】:2020-07-21 12:17:08
【问题描述】:

所以我创建并部署了一个教程 AWS CodeStar 项目 [https://github.com/aamalik7196/Testv4]。这些文件由 AWS 自己创建,用于运行一个简单的 Hello World 示例项目。

我更改的唯一更改是在 buildspec.yml 文件中创建测试报告,如下所示:

version: 0.2

phases:
  install:
    runtime-versions:
      python: 3.8
    commands:

      # Upgrade AWS CLI to the latest version
      - pip install --upgrade awscli

  pre_build:
    commands:

      # Discover and run unit tests in the 'tests' directory. For more information, see <https://docs.python.org/3/library/unittest.html#test-discovery>
      - python -m unittest discover tests

  build:
    commands:

      # Use AWS SAM to package the application by using AWS CloudFormation
      - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template template-export.yml

      # Do not remove this statement. This command is required for AWS CodeStar projects.
      # Update the AWS Partition, AWS Region, account ID and project ID in the project ARN on template-configuration.json file so AWS CloudFormation can tag project resources.
      - sed -i.bak 's/\$PARTITION\$/'${PARTITION}'/g;s/\$AWS_REGION\$/'${AWS_REGION}'/g;s/\$ACCOUNT_ID\$/'${ACCOUNT_ID}'/g;s/\$PROJECT_ID\$/'${PROJECT_ID}'/g' template-configuration.json

  # post-build:
  #   commands:
  #     - echo In post build phase

# only part added
reports:
  TestReport: # CodeBuild will create a report group called "TestReport".
    files: #Store all of the files
      - '**/*'

artifacts:
  files:
    - template-export.yml
    - template-configuration.json

repo 确实包含一个用于执行简单测试的文件夹。构建和部署成功[使用 AWS CodeStar],但是当我去查看报告选项卡时它是空的。我确实知道测试在构建日志中运行,但报告是空的。

【问题讨论】:

    标签: amazon-web-services unit-testing testing aws-codebuild aws-codestar


    【解决方案1】:

    运行find ./ 以确认生成了测试结果文件。同样在“报告”部分,指定确切的文件名。

    这是我用来检查和确认功能的示例构建规范:

    version: 0.2
    
    phases:
      install:
        runtime-versions:
          python: 3.8
      pre_build:
        commands:
          - aws --version
      post_build:
        commands:
          - wget https://raw.githubusercontent.com/qmetry/cucumber-javascript-example/master/test-result.json
          - find ./ 
    
    reports:
      rspec:
        files:
          - 'test-result.json'
        file-format: CucumberJson
    

    【讨论】:

      猜你喜欢
      • 2020-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-21
      相关资源
      最近更新 更多