Run Nunit Test in Git Actions for .Net Framework

Viewed 1440

I'm using NUnit.Framework to test my .NET Framework project. I want to run my tests via GitHub Actions. Yml file:

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

In response I get : No tests is available. I'm tried to run tests via MsBuild with the following command :

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

I'm receive the same notification that no tests is available. enter image description here

2 Answers
  1. Install NuGet Package NUnit.ConsoleRunner
  2. Remove your step "Setup VSTest and add to PATH" (unnecessary)
  3. change your step "Run VSTest" like so

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

i solved this by installing the NUnit.ConsoleRunner via nuget install:

  - 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
Related