GHPReporter / Ghpr.NUnit

Adapter for NUnit 3 (generate HTML report for NUnit 3)
http://ghpreporter.github.io/
MIT License
35 stars 14 forks source link

Integrating with .Net Core test project #77

Closed zubr7 closed 4 years ago

zubr7 commented 4 years ago

Describe the bug First of all I'd like to say thank you for your project! Unfortunately, I failed to integrate GHPReporter into my project (.Net Core Nunit test project). I didn't receive a generated file.

To Reproduce Steps to reproduce the behavior:

  1. Added the entry below into 'C:\Users\windows_username.nuget\packages\nunit.consolerunner\3.11.1\tools\nunit.console.nuget.addins': 'addins/../../../Users/windows_username/.nuget/packages/ghpr.nunit/0.9.10/lib/netstandard2.0/Ghpr.NUnit.dll'
  2. Copied 'Ghpr.NUnit.Settings.json' file from 'C:\Users\windows_username.nuget\packages\ghpr.nunit\0.9.10\content' to the root of my project
  3. Checked that 'bin\Debug\netcoreapp3.1\' folder contains Ghpr.Core.dll, Ghpr.NUnit.dll, Ghpr.LocalFileSystem.dll, Ghpr.NUnit.Settings.json and Newtonsoft.Json.dll
  4. Run my tests by cmd: 'dotnet test -l trx -r report'

Expected behavior A HTML report should be generated. I checked the root of C drive, project root folder, 'bin', 'obj' folders.

Screenshots image image

Versions .Net Core 3.1 GHPReporter 0.9.10, Nunit 3.12.0, Nunit.ColsoleRunner 3.11.1,

elv1s42 commented 4 years ago

Hi @zubr7 , Thank you for the issue and sorry for the late response. The issue we are having here is that NUnit works a little bit different when running .NET Core tests, see the corresponding issue here: https://github.com/nunit/nunit-console/issues/487

So I had to create a new issue here: https://github.com/GHPReporter/Ghpr.NUnit/issues/57 The idea is that we need a new NuGet package which will be detected automatically by NUnit when running .NET Core tests.

For now, I think it may be possible to use Ghpr.Console package to generate the report from the .xml file with test results.

Thank you

elv1s42 commented 4 years ago

Hi @zubr7,

Now you should be able to use Ghpr.NUnit inside your .NET Core test projects.

The solution was to add a new .addins file which is detected by NUnit3TestAdapter.

So here is a short instruction on how to quickly set up a .NET Core NUnit test project with Ghpr.NUnit (I'm using VS19):

  1. Create a new test project from template: image

  2. Install other required NuGet packages, so the full list will be as follows:

    
    <PackageReference Include="Ghpr.NUnit" Version="0.9.11" />
    <PackageReference Include="nunit" Version="3.12.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
    <PackageReference Include="Ghpr.Core" Version="0.9.10" />
    <PackageReference Include="Ghpr.LocalFileSystem" Version="0.9.10" />
  3. Make sure to include Ghpr.NUnit.Settings.json and Ghpr.NUnit.addins files into your project (and mark them with Copy always attribute). You can find both files in the corresponding NuGet folder of the Ghpr.NUnit package (starting from v0.9.11): image

  4. Run your tests using dotnet test command: image

  5. See the report generated: image

Please feel free to reopen this issue or raise a new one in case there is something wrong with how the package works for .NET Core tests.

Thank you.