Home > MacOS > JetBrains Rider > Prefer CLI > XunitV3 > AppVeyor
Add the following packages to the test project:
dotnet add package Microsoft.NET.Test.Sdk
dotnet add package Verify.XunitV3 --prerelease
dotnet add package xunit.v3 --prerelease
dotnet add package xunit.runner.visualstudio --prerelease
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()
.
- 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 variants of verified and received have the following characteristics:
- UTF8 with a Byte order mark (BOM)
- Newlines as line-feed (lf)
- No trailing newline
This manifests in several ways:
All text extensions of *.verified.*
should have:
eol
set tolf
working-tree-encoding
set toUTF-8
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
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
Note that the above are suggested for subset of text extension. Add others as required based on the text file types being verified.
Conventions can be checked by calling VerifyChecks.Run()
in a test
public class VerifyChecksTests
{
[Fact]
public Task Run() =>
VerifyChecks.Run();
}
Install the Rider Plugin
Provides a mechanism for contextually accepting or rejecting snapshot changes inside the Rider test runner.
This is optional, but recommended.
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?
As such this feature needs to be disabled:
Add the following to [Solution].sln.DotSettings
.
<s:String x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestRunner/SpawnedProcessesResponse/@EntryValue">DoNothing</s:String>
ReSharper | Options | Tools | Unit Testing | Test Runner
File | Settings | Manage Layers | This computer | Edit Layer | Build, Execution, Deployment | Unit Testing | Test Runner
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.
dotnet add package Verify.DiffPlex
[ModuleInitializer]
public static void Initialize() =>
VerifyDiffPlex.Initialize();
Verify.Terminal is a dotnet tool for managing snapshots from the command line.
This is optional.
dotnet tool install -g verify.tool
public class Sample
{
[Fact]
public Task Test()
{
var person = ClassBeingTested.FindPerson();
return Verify(person);
}
}
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 MacOS:
Use a on_failure build step to call Push-AppveyorArtifact.
on_failure:
- ps: Get-ChildItem *.received.* -recurse | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
See also Pushing artifacts from scripts.