Getting Started Wizard

July 17, 2026 ยท View on GitHub

Home > Linux > JetBrains Rider > Prefer GUI > NUnit > Azure DevOps

Add NuGet packages

Add the following packages to the test project:

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.8.1" />
<PackageReference Include="NUnit" Version="4.6.1" />
<PackageReference Include="Verify.NUnit" Version="31.25.0" />
<PackageReference Include="NUnit3TestAdapter" Version="6.2.0" />

snippet source | anchor

Implicit Usings

All examples use Implicit Usings. Ensure <ImplicitUsings> is set to enable to ensure examples compile correctly.

<ImplicitUsings>enable</ImplicitUsings>

If ImplicitUsings are not enabled, substitute usages of Verify() with Verifier.Verify().

Conventions

Source Control Includes/Excludes

  • All *.received.* files should be excluded from source control.

eg. add the following to .gitignore

*.received.*

If using UseSplitModeForUniqueDirectory also include:

*.received/

All *.verified.* files should be committed to source control.

Text file settings

Text variants of verified and received have the following characteristics:

This manifests in several ways:

Source control settings

All text extensions of *.verified.* should have:

  • eol set to lf
  • working-tree-encoding set to UTF-8

Note: working-tree-encoding=UTF-8 is correct even though Verify writes files with a BOM. Git does not strip or add the BOM โ€” it passes through transparently. The UTF-8-BOM encoding would explicitly add a BOM on checkout and strip it on commit (so the internal blob differs from the working tree), but that is not the desired behavior since Verify writes the BOM itself and it should be preserved in the blob.

All Binary files should also be marked to avoid merging and line ending issues with binary files.

eg add the following to .gitattributes

*.verified.txt text eol=lf working-tree-encoding=UTF-8
*.verified.xml text eol=lf working-tree-encoding=UTF-8
*.verified.json text eol=lf working-tree-encoding=UTF-8
*.verified.bin binary

Line ending autocrlf

On Windows, if core.autocrlf is set to true, files may show as modified with no actual content changes. To fix this:

git config --global core.autocrlf input

EditorConfig settings

If modifying text verified/received files in an editor, it is desirable for the editor to respect the above conventions. For EditorConfig enabled the following can be used:

# Verify settings
[*.{received,verified}.{json,txt,xml}]
charset = utf-8-bom
end_of_line = lf
indent_size = unset
indent_style = unset
insert_final_newline = false
tab_width = unset
trim_trailing_whitespace = false

[*.{received,verified}.{json,xml,html,htm,yaml,svg}]
indent_size = 2
indent_style = space

Note that the above are suggested for subset of text extension. Add others as required based on the text file types being verified.

Conventions check

Conventions can be checked by calling VerifyChecks.Run() in a test

[TestFixture]
public class VerifyChecksTests
{
    [Test]
    public Task Run() =>
        VerifyChecks.Run();
}

snippet source | anchor

Rider Plugin

Install the Rider Plugin

Provides a mechanism for contextually accepting or rejecting snapshot changes inside the Rider test runner.

This is optional, but recommended.

Disable orphaned process detection

Resharper and Rider have a feature Check for orphaned processes spawned by test runner.

By default, a list of all processes that are launched by the executed tests. If some of theses processes do not exit after the test execution is over, ReSharper will suggest you to terminate the process. If your setup requires some processes started by the tests to continue running, you can clear this checkbox to avoid unnecessary notifications.

Since this project launches diff tools, it will trigger this feature and a dialog will show:

All unit tests are finished, but child processes spawned by the test runner process are still running. Terminate child process?

R# terminate process dialog

As such this feature needs to be disabled:

Disable for solution

Add the following to [Solution].sln.DotSettings.

<s:String x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestRunner/SpawnedProcessesResponse/@EntryValue">DoNothing</s:String>

Disable for machine

Resharper

ReSharper | Options | Tools | Unit Testing | Test Runner

Disable R# orphaned processes detection

Rider

File | Settings | Manage Layers | This computer | Edit Layer | Build, Execution, Deployment | Unit Testing | Test Runner

Disable R# orphaned processes detection

Treat "return value of pure method is not used" as error

Verify uses the PureAttribute to mark methods where the result of the method is expected to be used. For example awaiting the call to Verify(). Rider and ReSharper can be configured to treat an un-used return value as an error. Add the following to the .editorconfig file:

[*.cs]
resharper_return_value_of_pure_method_is_not_used_highlighting = error

DiffPlex

The text comparison behavior of Verify is pluggable. The default behaviour, on failure, is to output both the received and the verified contents as part of the exception. This can be noisy when verifying large strings.

Verify.DiffPlex changes the text compare result to highlighting text differences inline.

This is optional, but recommended.

Add the NuGet

<PackageReference Include="Verify.DiffPlex" Version="*" />

Enable

[ModuleInitializer]
public static void Initialize() =>
    VerifyDiffPlex.Initialize();

Sample Test

[TestFixture]
public class Sample
{
    [Test]
    public Task Test()
    {
        var person = ClassBeingTested.FindPerson();
        return Verify(person);
    }
}

snippet source | anchor

Diff Tool

Verify supports many Diff Tools for comparing received to verified. While IDEs are supported, due to their MDI nature, using a different Diff Tool is recommended.

Tools supported by Linux:

Getting .received in output on Azure DevOps

Directly after the test runner step add a build step to set a flag if the testrunner failed. This is done by using a failed condition. This flag will be evaluated in the CopyFiles and PublishBuildArtifacts steps below.

- task: CmdLine@2
  displayName: 'Set flag to publish Verify *.received.* files when test step fails'
  condition: failed()
  inputs:
    script: 'echo "##vso[task.setvariable variable=publishverify]Yes"'

Since the PublishBuildArtifacts step in DevOps does not allow a wildcard it is necessary to stage the 'received' files before publishing:

- task: CopyFiles@2
  condition: eq(variables['publishverify'], 'Yes')
  displayName: 'Copy Verify *.received.* files to Artifact Staging'
  inputs:
    contents: '**/*.received.*' 
    targetFolder: '$(Build.ArtifactStagingDirectory)/Verify'
    cleanTargetFolder: true
    overWrite: true

Publish the staged files as a build artifact:

- task: PublishBuildArtifacts@1
  displayName: 'Publish Verify *.received.* files as Artifacts'
  name: 'verifypublish'
  condition: eq(variables['publishverify'], 'Yes')
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)/Verify'
    ArtifactName: 'Verify'
    publishLocation: 'Container'