【问题标题】:Run Nunit Test in Git Actions for .Net Framework在 .Net Framework 的 Git 操作中运行 Nunit 测试
【发布时间】:2021-08-18 13:58:30
【问题描述】:

我正在使用 NUnit.Framework 来测试我的 .NET Framework 项目。我想通过 GitHub Actions 运行我的测试。 yml 文件:

build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
  uses: actions/setup-dotnet@v1
  with:
    dotnet-version: '3.0.x'
- name: Setup MSBuild Path
  uses: microsoft/setup-msbuild@v1
- name: Build
  run:  msbuild.exe .\CalcStatistics\CalcStats\CalcStats.sln
- name: Setup VSTest and add to PATH
  uses: darenm/Setup-VSTest@v1
- name: Run VSTest
  id: run_vstest
  run: vstest.console.exe .\CalcStatistics\CalcStats\CalcStatsTests\bin\Debug\CalcStatsTests.dll /Platform:x64

作为回应,我得到:没有可用的测试。 我尝试使用以下命令通过 MsBuild 运行测试:

run:& "$(vswhere -property installationPath)\Common7\IDE\MSTest.exe" /testcontainer:.\CalcStatistics\CalcStats\CalcStatsTests\bin\Debug\CalcStatsTests.dll

我收到了相同的通知,即没有可用的测试。

【问题讨论】:

    标签: .net devops github-actions .net-framework-version


    【解决方案1】:
    1. 安装 NuGet 包NUnit.ConsoleRunner
    2. 删除您的步骤“设置 VSTest 并添加到 PATH”(不必要)
    3. 像这样更改您的步骤“运行 VSTest”

    run: packages\NUnit.ConsoleRunner.3.12.0\tools\nunit3-console.exe TestProject\bin\Debug\TestProject.dll

    【讨论】:

      【解决方案2】:

      我通过 nuget install 安装 NUnit.ConsoleRunner 解决了这个问题:

        - name: Install NUnit.ConsoleRunner
           run: nuget install NUnit.ConsoleRunner -Version 3.13.0 -DirectDownload -OutputDirectory .
              
        - name: Run UnitTests
           run: ./NUnit.ConsoleRunner.3.13.0/tools/nunit3-console.exe  path/to/test.dll
      

      【讨论】:

        猜你喜欢
        • 2016-08-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多