Skip to content
ConsoleMonster
Class

TestRecord

ConsoleMonster.TestRuns

Namespace
ConsoleMonster.TestRuns
Assembly
ConsoleMonster
Modifiers
sealed
Attributes
Fluent

One finished test of a TestRun: where it lives (container, blocks), how it ended, how long it took, and for a failure the message and the location. Test frameworks are mapped onto it by adapters (for example Invoke-ConsolePester for Pester). Assessment engines add a TestRecord.Group (the product or area a check belongs to), a TestRecord.Severity and, for checks that did not run, a TestRecord.Reason.

Inheritance

  • object
  • TestRecord

Usage

Explore 52 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 27

Constructors

public TestRecord(string container, string name, StatusKind status) #

Creates a record.

Parameters

container string required
The container key (a test file, usually its full path).
name string required
The test name (expanded, as reported).
status ConsoleMonster.Styling.StatusKind required
How it ended: Pass, Fail, Error (could not run to a verdict), Investigate, Skip, NotRun, Warn (inconclusive) or Pending (not reported).

Methods

public static StatusKind ParseStatus(string? result) #

The status for a test framework's result word: Passed, Failed, Skipped, Inconclusive and NotRun (Pester, xUnit, NUnit and MSTest use these words), Error (or Errored, Timeout), Investigate and NotExecuted. Inconclusive is a warning; anything else is Pending.

Parameters

result string? required
The result word.

Returns

StatusKind The status.

Properties

public string Container { get; } #

The container key.

public string Name { get; } #

The test name.

public StatusKind Status { get; } #

How the test ended.

public IReadOnlyList<string> Blocks { get; set; } #

The enclosing blocks, outermost first (Describe, Context).

public TimeSpan Duration { get; set; } #

How long the test took.

public string? Message { get; set; } #

The failure message, or null.

public string? File { get; set; } #

The file of the failing line (or of the test), or null.

public int Line { get; set; } #

The failing line (or the test's first line), or 0 when unknown.

public string? ErrorType { get; set; } #

The exception type of an error that is not an assertion (shown before the message), or null.

public Severity? Severity { get; set; } #

How serious the finding is when the check fails, or null. A summary shows the worst severity among the records that did not pass.

public string? Group { get; set; } #

The group a summary counts the record under (a product, an area, a category), or null to count it under its container.

public string? ReasonCode { get; set; } #

A stable code for why a check was skipped or not run (NotApplicable, ServiceNotConnected, DryRun), or null. Summaries count skipped and not-run records by this code.

public string? Reason { get; set; } #

A sentence for why a check was skipped or not run, or null. Summaries use it when there is no code.

public bool IsBlockFailure { get; set; } #

Whether the record stands for a block or container that failed outside a test (setup, teardown, discovery).

Extension Methods

public static TestRecord BlockFailure(TestRecord testRecord, bool value = true) #

Sets TestRecord.IsBlockFailure: Whether the record stands for a block or container that failed outside a test (setup, teardown, discovery).

Parameters

testRecord ConsoleMonster.TestRuns.TestRecord required
The instance.
value bool = true optional
The value; true when omitted.

Returns

TestRecord The same instance.

Examples

// C# initializer or property         // C# fluent
testRecord.IsBlockFailure = value;    testRecord.BlockFailure(value);
public static TestRecord Blocks(TestRecord testRecord, IReadOnlyList<string> value) #

Sets TestRecord.Blocks: The enclosing blocks, outermost first (Describe, Context).

Parameters

testRecord ConsoleMonster.TestRuns.TestRecord required
The instance.
value System.Collections.Generic.IReadOnlyList<string> required
The value.

Returns

TestRecord The same instance.

Examples

// C# initializer or property    // C# fluent
testRecord.Blocks = value;       testRecord.Blocks(value);
public static TestRecord Duration(TestRecord testRecord, TimeSpan value) #

Sets TestRecord.Duration: How long the test took.

Parameters

testRecord ConsoleMonster.TestRuns.TestRecord required
The instance.
value System.TimeSpan required
The value.

Returns

TestRecord The same instance.

Examples

// C# initializer or property    // C# fluent
testRecord.Duration = value;     testRecord.Duration(value);
public static TestRecord ErrorType(TestRecord testRecord, string? value) #

Sets TestRecord.ErrorType: The exception type of an error that is not an assertion (shown before the message), or null.

Parameters

testRecord ConsoleMonster.TestRuns.TestRecord required
The instance.
value string? required
The value.

Returns

TestRecord The same instance.

Examples

// C# initializer or property    // C# fluent
testRecord.ErrorType = value;    testRecord.ErrorType(value);
public static TestRecord File(TestRecord testRecord, string? value) #

Sets TestRecord.File: The file of the failing line (or of the test), or null.

Parameters

testRecord ConsoleMonster.TestRuns.TestRecord required
The instance.
value string? required
The value.

Returns

TestRecord The same instance.

Examples

// C# initializer or property    // C# fluent
testRecord.File = value;         testRecord.File(value);
public static TestRecord Group(TestRecord testRecord, string? value) #

Sets TestRecord.Group: The group a summary counts the record under (a product, an area, a category), or null to count it under its container.

Parameters

testRecord ConsoleMonster.TestRuns.TestRecord required
The instance.
value string? required
The value.

Returns

TestRecord The same instance.

Examples

// C# initializer or property    // C# fluent
testRecord.Group = value;        testRecord.Group(value);
public static TestRecord Line(TestRecord testRecord, int value) #

Sets TestRecord.Line: The failing line (or the test's first line), or 0 when unknown.

Parameters

testRecord ConsoleMonster.TestRuns.TestRecord required
The instance.
value int required
The value.

Returns

TestRecord The same instance.

Examples

// C# initializer or property    // C# fluent
testRecord.Line = value;         testRecord.Line(value);
public static TestRecord Message(TestRecord testRecord, string? value) #

Sets TestRecord.Message: The failure message, or null.

Parameters

testRecord ConsoleMonster.TestRuns.TestRecord required
The instance.
value string? required
The value.

Returns

TestRecord The same instance.

Examples

// C# initializer or property    // C# fluent
testRecord.Message = value;      testRecord.Message(value);
public static TestRecord Reason(TestRecord testRecord, string? value) #

Sets TestRecord.Reason: A sentence for why a check was skipped or not run, or null. Summaries use it when there is no code.

Parameters

testRecord ConsoleMonster.TestRuns.TestRecord required
The instance.
value string? required
The value.

Returns

TestRecord The same instance.

Examples

// C# initializer or property    // C# fluent
testRecord.Reason = value;       testRecord.Reason(value);
public static TestRecord ReasonCode(TestRecord testRecord, string? value) #

Sets TestRecord.ReasonCode: A stable code for why a check was skipped or not run (NotApplicable, ServiceNotConnected, DryRun), or null. Summaries count skipped and not-run records by this code.

Parameters

testRecord ConsoleMonster.TestRuns.TestRecord required
The instance.
value string? required
The value.

Returns

TestRecord The same instance.

Examples

// C# initializer or property     // C# fluent
testRecord.ReasonCode = value;    testRecord.ReasonCode(value);
public static TestRecord Severity(TestRecord testRecord, Severity? value) #

Sets TestRecord.Severity: How serious the finding is when the check fails, or null. A summary shows the worst severity among the records that did not pass.

Parameters

testRecord ConsoleMonster.TestRuns.TestRecord required
The instance.
value ConsoleMonster.Styling.Severity? required
The value.

Returns

TestRecord The same instance.

Examples

// C# initializer or property    // C# fluent
testRecord.Severity = value;     testRecord.Severity(value);