0

I have a suite of NUnit tests. When they finish, I get a TestResults.xml file. This file is very large and dense; I'd like to be able to peruse a simple human-readable report of the underlying results. I'm led to believe that the provided nunit-console program can do that, but I can't figure out how.

How can I print the information described by TestResults.xml with nunit-console?

Note that running the tests is not the problem; my problem is figuring out how to display the results on the command-line. I can't change how the tests are run, but I can do whatever I want with the results file.

JesseTG
  • 2,025
  • 1
  • 24
  • 48
  • You can find various NUnit report generators on GitHub and other places. One example I was looking at the other day was `Ghpr.NUnit`, which generates a HTML/JS report. It requires some setup obviously, but after that it generates whenever you run tests using the `nunit-console`. The result is bit complex for my taste, and I'm still looking for a report generator that makes sense to me, but you might find it to be useful. You can view a sample report on the GitHub page. https://github.com/GHPReporter/Ghpr.NUnit – srk Aug 30 '19 at 16:58

1 Answers1

0

The Test Result file isn't intended to be human-readable, except when used for debugging. It's a source for all the data about a test run from which human-readable reports may be generated.

There are two ways to generate a report

  1. As a part of the test run itself.
  2. After the run is finished, using the test result xml file.

Reports generated as part of the test run require a report writing extension. You would write such an extension following the documentation to produce the report in whatever format you require, like text or html, and give it a unique tag likemyreport.

You would install your extension and could then run the console runner including an option like

 --result:somefile.html;format=myreport

As you may guess, creating your own extension is a relatively advanced use of NUnit.

Another option, if you are familiar with XSLT processing, is to use the built-in report format user, together with an XSLT transform. In that case, the option is something like

 --result:somefile.html;transform=mytransform.xslt

You can also produce a report after the run is finished using the XML output file. The NUnit console program is not used in this case. You must use some standard program for creating reports from NUnit output (or a generic program taking XSLT transforms) or write your own program.

Charlie
  • 12,928
  • 1
  • 27
  • 31