User456789
User456789

Reputation: 397

How can I export the results of a C# unit test?

Is there a way to export the result of a unit test?

When I run NUnit, can I get formal output saying what methods have been tested and out of those, which one failed and which passed?

Upvotes: 2

Views: 3679

Answers (1)

RagtimeWilly
RagtimeWilly

Reputation: 5445

You can specify the test results to be outputted to a file:

Redirecting Text Output

Output created by the test, which is normally shown on the console, may be redirected to a file. The following command redirects standard output to the file TestResult.txt:

  nunit-console nunit.tests.dll /out:TestResult.txt

The following command redirects standard error output to the StdErr.txt file.

  nunit-console nunit.tests.dll /err:StdErr.txt

Note:This option only redirects output produced by the tests, together with selected NUnit output that is interspersed with the test output. It does not redirect all console output. If you want to redirect all output to a file, you should use command line redirection as supported by the shell you are using. This option exists for the purpose of separating test output from other output, such as the NUnit summary report.

From the NUnit documentation.

I just tested against one of my test assemblies by completing the following steps:

  1. Downloaded and installed latest version of NUnit
  2. Added 'C:\Program Files (x86)\NUnit 2.6.4\bin' to System Path
  3. Navigated to where my assembly was in the command prompt
  4. Ran nunit-console MyTests.dll /out:TestResult.txt

The results were then written to TestResult.txt in the same directory.

Upvotes: 2

Related Questions