Table of Contents

Class DotnetTestOptions

Namespace
Invex.Atom.Module.Dotnet.Cli
Assembly
Invex.Atom.Module.Dotnet.dll
public sealed record DotnetTestOptions
Inheritance
object
DotnetTestOptions

Constructors

DotnetTestOptions()

public DotnetTestOptions()

Properties

Arch

The target architecture.

public string? Arch { get; init; }

Property Value

string

ArtifactsPath

The artifacts path. All output from the project, including build, publish, and pack output, will go in subfolders under the specified path.

public string? ArtifactsPath { get; init; }

Property Value

string

Blame

Runs the tests in blame mode. This option is helpful in isolating problematic tests that cause the test host to crash or hang, but it does not create a memory dump by default.

When a crash is detected, it creates an sequence file in TestResults/guid/guid_Sequence.xml that captures the order of tests that were run before the crash.

Based on the additional settings, hang dump or crash dump can also be collected.

Example: Timeout the test run when test takes more than the default timeout of 1 hour, and collect crash dump when the test host exits unexpectedly. (Crash dumps require additional setup, see below.) dotnet test --blame-hang --blame-crash Example: Timeout the test run when a test takes more than 20 minutes and collect hang dump. dotnet test --blame-hang-timeout 20min

public bool? Blame { get; init; }

Property Value

bool?

BlameCrash

Runs the tests in blame mode and collects a crash dump when the test host exits unexpectedly. This option depends on the version of .NET used, the type of error, and the operating system.

For exceptions in managed code, a dump will be automatically collected on .NET 5.0 and later versions. It will generate a dump for testhost or any child process that also ran on .NET 5.0 and crashed. Crashes in native code will not generate a dump. This option works on Windows, macOS, and Linux.

Crash dumps in native code, or when targetting .NET Framework, or .NET Core 3.1 and earlier versions, can only be collected on Windows, by using Procdump. A directory that contains procdump.exe and procdump64.exe must be in the PATH or PROCDUMP_PATH environment variable.

The tools can be downloaded here: https://docs.microsoft.com/sysinternals/downloads/procdump

To collect a crash dump from a native application running on .NET 5.0 or later, the usage of Procdump can be forced by setting the VSTEST_DUMP_FORCEPROCDUMP environment variable to 1.

Implies --blame.

public bool? BlameCrash { get; init; }

Property Value

bool?

BlameCrashCollectAlways

Enables collecting crash dump on expected as well as unexpected testhost exit.

public bool? BlameCrashCollectAlways { get; init; }

Property Value

bool?

BlameCrashDumpType

The type of crash dump to be collected. Supported values are full (default) and mini. Implies --blame-crash.

public string? BlameCrashDumpType { get; init; }

Property Value

string

BlameHang

Run the tests in blame mode and enables collecting hang dump when test exceeds the given timeout.

public bool? BlameHang { get; init; }

Property Value

bool?

BlameHangDumpType

The type of crash dump to be collected. The supported values are full (default), mini, and none. When 'none' is used then test host is terminated on timeout, but no dump is collected. Implies --blame-hang.

public string? BlameHangDumpType { get; init; }

Property Value

string

BlameHangTimeout

Per-test timeout, after which hang dump is triggered and the testhost process is terminated. Default is 1h. The timeout value is specified in the following format: 1.5h / 90m / 5400s / 5400000ms. When no unit is used (e.g. 5400000), the value is assumed to be in milliseconds. When used together with data driven tests, the timeout behavior depends on the test adapter used. For xUnit, NUnit and MSTest 2.2.4+ the timeout is renewed after every test case, For MSTest before 2.2.4, the timeout is used for all testcases.

public string? BlameHangTimeout { get; init; }

Property Value

string

Collect

The friendly name of the data collector to use for the test run. More info here: https://aka.ms/vstest-collect

public IEnumerable<string>? Collect { get; init; }

Property Value

IEnumerable<string>

Configuration

The configuration to use for running tests. The default for most projects is 'Debug'.

public string? Configuration { get; init; }

Property Value

string

Diag

Enable verbose logging to the specified file.

public string? Diag { get; init; }

Property Value

string

DisableBuildServers

Force the command to ignore any persistent build servers.

public bool? DisableBuildServers { get; init; }

Property Value

bool?

Environment

Sets the value of an environment variable. Creates the variable if it does not exist, overrides if it does. This will force the tests to be run in an isolated process. This argument can be specified multiple times to provide multiple variables.

Examples: -e VARIABLE=abc -e VARIABLE="value with spaces" -e VARIABLE="value;seperated with;semicolons" -e VAR1=abc -e VAR2=def -e VAR3=ghi

public IReadOnlyDictionary<string, string>? Environment { get; init; }

Property Value

IReadOnlyDictionary<string, string>

Filter

Run tests that match the given expression. Examples: Run tests with priority set to 1: --filter "Priority = 1" Run a test with the specified full name: --filter "FullyQualifiedName=Namespace.ClassName.MethodName" Run tests that contain the specified name: --filter "FullyQualifiedName~Namespace.Class" See https://aka.ms/vstest-filtering for more information on filtering support.

public string? Filter { get; init; }

Property Value

string

Framework

The target framework to run tests for. The target framework must also be specified in the project file.

public string? Framework { get; init; }

Property Value

string

Interactive

Allows the command to stop and wait for user input or action (for example to complete authentication).

public bool? Interactive { get; init; }

Property Value

bool?

ListTests

List the discovered tests instead of running the tests.

public bool? ListTests { get; init; }

Property Value

bool?

Logger

The logger to use for test results. Examples: Log in trx format using a unique file name: --logger trx Log in trx format using the specified file name: --logger "trx;LogFileName=<TestResults.trx>" See https://aka.ms/vstest-report for more information on logger arguments.

public IEnumerable<string>? Logger { get; init; }

Property Value

IEnumerable<string>

NoBuild

Do not build the project before testing. Implies --no-restore.

public bool? NoBuild { get; init; }

Property Value

bool?

Run test(s), without displaying Microsoft Testplatform banner

public bool? NoLogo { get; init; }

Property Value

bool?

NoRestore

Do not restore the project before building.

public bool? NoRestore { get; init; }

Property Value

bool?

Os

The target operating system.

public string? Os { get; init; }

Property Value

string

Output

The output directory to place built artifacts in.

public string? Output { get; init; }

Property Value

string

Property

public IReadOnlyDictionary<string, string>? Property { get; init; }

Property Value

IReadOnlyDictionary<string, string>

ResultsDirectory

The directory where the test results will be placed. The specified directory will be created if it does not exist.

public string? ResultsDirectory { get; init; }

Property Value

string

Runtime

The target runtime to test for.

public string? Runtime { get; init; }

Property Value

string

Settings

The settings file to use when running tests.

public string? Settings { get; init; }

Property Value

string

Target

Build these targets in this project. Use a semicolon or a comma to separate multiple targets, or specify each target separately.

public string[]? Target { get; init; }

Property Value

string[]

TestAdapterPath

The path to the custom adapters to use for the test run.

public IEnumerable<string>? TestAdapterPath { get; init; }

Property Value

IEnumerable<string>

Verbosity

Set the MSBuild verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic].

public VerbosityOptions? Verbosity { get; init; }

Property Value

VerbosityOptions?

Methods

ToArguments()

Converts these options to individual command-line arguments, in schema order.

public IReadOnlyList<string> ToArguments()

Returns

IReadOnlyList<string>

The arguments. Each option name and each value is a separate element, so values need no quoting.