Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate result report testing with xunit using .NET core

I have a project ASP.NET core which I integrate unit test with xUnit , Everything work fine but I want to genrate xml report test to integrate in jenkins . Any help please :)

My project.json is :

{
  "version": "1.0.0-*",
  "testRunner": "xunit",
  "dependencies": {
    "xunit": "2.2.0-beta2-build3300",
    "Microsoft.NETCore.App": "1.1.0",
    "dotnet-test-xunit": "2.2.0-preview2-build1029"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
      }
    }
  },
  "runtimes": {
    "ubuntu.16.04-x64": {},
    "win10-x64": {},
    "debian.8-x64": {},
    "win81-x64": {}
  }

}

I'm using the plugin xunit jenkins to display my result test . If their are another way tell me .

like image 935
Abbes Yassine Avatar asked Jan 17 '17 01:01

Abbes Yassine


2 Answers

Old thread but can be useful. In .Net Core 3.1 you can use --logger html to get a read friendly report. dotnet test --logger html

Using:

.Net Core 3.1,
Xunit 2.4.1
like image 123
Patric Avatar answered Nov 07 '22 16:11

Patric


I had the same issue in .NET Core 2.0 and dotnet test does not have a -xml switch. So, I relied on a custom logger to do the job:

  1. add NunitXml.TestLogger package to the test project

  2. Run tests using this logger:

    dotnet test "project.csproj" --no-build --verbosity normal --logger:"nunit;LogFilePath=xunit_results.xml"
    

The output is compatible with NUnit results and be used to generate fancy reports like those obtained using ReportUnit.

like image 39
Alexei - check Codidact Avatar answered Nov 07 '22 16:11

Alexei - check Codidact