'Capturing test output with XUnit.Net and VS2017
VS2017 Community Edition comes with test project templates for Xunit pre-installed. I have a Dotnet Standard 1.4 class library and a Dotnet Core 1.1 XUnit test project. This works well, everything builds, I can run all tests from the Visual Studio Test Explorer, and if my tests write to an ITestOutputHelper the Test Explorer shows an 'Output' link where I can view the output of the tests.
The problem is that if I have a load of tests I don't want to have to click on every test, and then on every 'Output' link in order to view the results. instead I want to see the results in some sort of output file.
The Xunit documentation indicates that it does have the ability to output test results in xml.
http://xunit.github.io/docs/format-xml-v2.html
But it doesn't explain how to get it to do it.
How can I get Xunit to save test output to a file?
Solution 1:[1]
xUnit logger can generate xml reports in the xUnit v2 format (https://xunit.github.io/docs/format-xml-v2.html).
Add a reference to the xUnit Logger nuget package in test project.
Use the following command line in tests:
dotnet test --test-adapter-path:. --logger:xunitTest results are generated in the
TestResultsdirectory relative to thetest.csproj. A path for the report file can be specified as follows:dotnet test --test-adapter-path:. --logger:xunit;LogFilePath=loggerFile.xmlloggerFile.xmlwill be generated in the same directory astest.csproj.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | shA.t |
