NUnit 3 test reporting

If you are not using NUnit but are using C# for your tests, see the C# documentation.

Installation

Tesults provides an extension for NUnit, specifically for NUnit 3 for NUnit.ConsoleRunner.

The package is hosted on The NuGet Gallery. Run this command in Package Manager Console.

Install-Package Tesults.NUnit

Alternatively install Tesults.NUnit using the GUI in Visual Studio from Tools > NuGet Package Manager > Manage NuGet Packages for Solution...

The Tesults NUnit extension is compatible with the .NET Framework only at this time, not .NET Standard or .NET Core. The projects you add the Tesults NUnit extension too must target 4.6.1 or higher.

Configuration

Install the NUnit.ConsoleRunner NuGet package (along with NUnit and Tesults.NUnit packages).

Install-Package NUnit.ConsoleRunner -Version 3.10.0

NUnit.ConsoleRunner version 3.10.0 is required. Do not install 3.11.1 because there is a regression bug in that version that means test parameters are not passed through to NUnit (https://github.com/nunit/nunit-console/issues/755). If you are using the NuGet Package Manager you can downgrade to 3.10.0 from within the UI.

Additional configuration is required for NUnit to recognize the Tesults NUnit extension. A file with the extension .addins must be created, the name doesn't matter, you can call it tesults.addins. This file must be added to the NUnit.ConsoleRunner package. Open your test project in Explorer and navigate to packages > NUnit.ConsoleRunner > tools. This directory contains the nunit3-console.dll and others. This is where the tesults.addins file must be added. The contents of the file must provide the path to Tesults.NUnit.dll, where the path is relative to the addins file, in most cases the contents would be:

tesults.addins

../../Tesults.NUnit.1.1.0/lib/net472/Tesults.NUnit.dll

If you are experiencing difficulties with this step, please contact us and we will help guide you. Unfortunately this is a necessary step for registering extensions with NUnit. Please also note that this extension is intended for use with the NUnit.ConsoleRunner, and not the Visual Studio NUnit3TestAdapter, because the test adapter does not recognize extensions. You will need to run your tests with the NUNIT3-CONSOLE command if you want result to upload to Tesults, whether locally or within your build and continuous integration system.

tesults-targetRequired

A target token must be provided to upload to Tesults, if this arg is not provided Tesults.NUnit does not attempt upload, effectively disabling it. Get your target token from the configuration menu in the Tesults web interface.

Inline method

NUNIT3-CONSOLE ./bin/Release/tests.dll --tp tesults-target=eyJ0eXAiOiJ

In this case, the target token is supplied directly or inline in the commandline args. This is the simplest approach.

Key method

NUNIT3-CONSOLE ./bin/Release/tests.dll --tp tesults-target=target1

In this case, Tesults.NUnit will automatically look up the value of the token based on a key value from a configuration file. The config file should be a typical .config file for C# and the path must be passed in using the tesults-config arg. See below for details.


tesults-configOptional

Example

NUNIT3-CONSOLE [inputfiles] [options] --tp tesults-config=C:\path-to-config

Example config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
  <add key="target1" value="eyJ0eXAiOiJKV1..."/>
  <add key="target2" value="eyJ0eXAiOiJKV2..."/>
  <add key="tesults-files" value="C:\path-to\files"/>
  <add key="tesults-build-name" value="1.0.0"/>
  <add key="tesults-build-desc" value="build description here"/>
  <add key="tesults-build-result" value="pass"/>
  <add key="tesults-build-reason" value="reason here"/>
</appSettings>
</configuration>

Or something more descriptive about the targets:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
  <add key="web-qa-env" value="eyJ0eXAiOiJKV1..."/>
  <add key="web-staging-env" value="eyJ0eXAiOiJKV12..."/>
  <add key="web-prod-env" value="eyJ0eXAiOiJKV13..."/>
  <add key="ios-qa-env" value="eyJ0eXAiOiJKV14..."/>
  <add key="ios-staging-env" value="eyJ0eXAiOiJKV15..."/>
  <add key="ios-prod-env" value="eyJ0eXAiOiJKV16..."/>
  <add key="android-qa-env" value="eyJ0eXAiOiJKV17..."/>
  <add key="android-staging-env" value="eyJ0eXAiOiJKV18..."/>
  <add key="android-prod-env" value="eyJ0eXAiOiJKV19..."/>
</appSettings>
</configuration>

The config file can contain values not just for target look up but for all of the args below too. If the same arg is provided in both the command and in a config file the command arg takes priority.

Basic configuration complete

At this point the Tesults.NUnit extension will push results to Tesults when you run the NUNIT3-CONSOLE command. The Tesults.NUnit extension requires the tesults-target arg be supplied to indicate which target to use otherwise the extension is effectively disabled and you will see this message in the console output 'Tesults disabled. No tesults-target param supplied.' See above for complete details.

Example:

NUNIT3-CONSOLE ./bin/Release/tests.dll --tp tesults-target=token --tp tesults-config=C:\path-to-config

The 'token' should be replaced with your Tesults target token. Tesults target tokens can be copied on project creation, new target creation or can be regenerated from the configuration menu.

Files

During a test run, save test generated files such as logs and screenshots to a local temporary directory. At the end of the test run all files will automatically be saved to Tesults as long as you save files in the directory structure below.
  • expanded temporary
    • expanded Test suite name
      • expanded Test case name
        • file 1
        • file 2

For example:

  • expanded temporary
    • expanded Test Suite A
      • expanded Test 1
        • test.log
        • screenshot.png
      • expanded Test 2
        • test.log
        • screenshot.png
    • expanded Test Suite B
      • expanded Test 3
        • metrics.csv
        • error.log
      • expanded Test 4
        • test.log

If not using test suites then omit the suite directories:

  • expanded temporary
    • expanded Test 1
      • test.log
      • screenshot.png
    • expanded Test 2
      • test.log
      • screenshot.png
tesults-filesOptional

Provide the top-level directory where files generated during testing are saved for the running test run. Files, including logs, screen captures and other artifacts will be automatically uploaded.

NUNIT3-CONSOLE [inputfiles] [options] --tp tesults-files=C:\path-to-files\temporary

This is one area where Tesults.NUnit is opinionated and requires that files generated during a test run be saved locally temporarily within a specific directory structure.

Store all files in a temporary directory as your tests run. After Tesults upload is complete, delete the temporary directory or just have it overwritten on the next test run.

Within this temporary directory create subdirectories matching the test case name.

The suite name matches the [TestFixture] and test case name matches the [Test] method name.

Caution: If uploading files the time taken to upload is entirely dependent on your network speed. Typical office upload speeds of 100 - 1000 Mbps should allow upload of even hundreds of files quite quickly, just a few seconds, but if you have slower access it may take hours. We recommend uploading a reasonable number of files for each test case. The upload method blocks while uploading test results and files. When starting out test without files first to ensure everything is setup correctly.

Build

tesults-build-nameOptional

Use this to report a build version or name for reporting purposes.

NUNIT3-CONSOLE [inputfiles] [options]--tp tesults-build-name=1.0.0

tesults-build-resultOptional

Use this to report the build result, must be one of [pass, fail, unknown].

NUNIT3-CONSOLE [inputfiles] [options] --tp tesults-build-result=pass

tesults-build-descOptional

Use this to report a build description for reporting purposes.

NUNIT3-CONSOLE [inputfiles] [options] --tp tesults-build-desc=description

tesults-build-reasonOptional

Use this to report a build failure reason.

NUNIT3-CONSOLE [inputfiles] [options] --tp tesults-build-reason="reason"

Consolidating multiple test results submissions into one test run

If you execute multiple test runs in parallel or serially for the same build or release and results are submitted to Tesults within each run, separately, you will find that multiple test runs are generated on Tesults. This is because the default behavior on Tesults is to treat each results submission as a separate test run. This behavior can be changed from the configuration menu. Click 'Results Consolidation By Build' from the Configure Project menu to enable and disable consolidation by target. Enabling consolidation will mean that multiple test runs submitted with the same build name will be consolidated into a single test run.

Dynamically created test cases should have static names

If you dynamically create test cases, such as test cases with variable values, we recommend that the test suite and test case names themselves be static. Provide the variable data information in the test case description or other custom fields but try to keep the test suite and test name static. This way you will you benefit from a range of features Tesults has to offer including test case failure assignment and historical results analysis. You need not make your tests any less dynamic, variable values can still be reported within test case details.

Proxy servers

Does your corporate/office network run behind a proxy server? Contact us and we will supply you with a custom API Library for this case. Without this results will fail to upload to Tesults.

Have questions or need help? Contact us