首页 > 解决方案 > 如何在 GitHub Actions 中配置 dotnet-tests-report?

问题描述

我有一些使用 Azure Devops 的经验,而且我刚刚开始使用 GitHub Actions。

我的项目包括可以使用此操作进行测试的自动化测试。

但是,我认为我应该能够做到以下几点:

  1. 将测试配置为在发布模式下构建和运行。
  2. 如果测试失败,则使作业失败。

我发现保持简单很重要,因此我不想切换到此处描述的解决方案,因为这意味着创建多个操作并要求我的同事下载工件以查看测试结果。

我怎样才能制作出这些漂亮的测试报告,但仍然能够配置它?

标签: unit-testingasp.net-corecontinuous-integrationgithub-actions

解决方案


这一切都在动作定义中描述:

[...]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: use this action, test solution dir
        uses: zyborg/dotnet-tests-report@v1
        with:
          project_path: tests/My.Project.Tests
          report_name: my_project_tests
          report_title: My Project Tests
          github_token: ${{ secrets.GITHUB_TOKEN }}
          # If set to true, the build will fail if at least one test fails
          fail_build_on_failed_tests: true
          # the configuration passed to the msbuild process, such as `Release` or `Debug`.
          msbuild_configuration: Release

推荐阅读