Skip to content
ConsoleMonster
Class

TestRunText

ConsoleMonster.TestRuns

Namespace
ConsoleMonster.TestRuns
Assembly
ConsoleMonster
Modifiers
static

The text of a test run, shared by the live view, the summary and the stream lines, so a failure reads the same everywhere: the status symbol, the blocks and test name joined by the breadcrumb chevron, expected against actual (or the message), and the file and line as a link.

Inheritance

  • object
  • TestRunText

Methods

public static string FailureLine(TestRecord record, IGlyphSet glyphs) #

One line for a failure in stream output: symbol, path, the first message line or expected and actual, and the location.

Parameters

record ConsoleMonster.TestRuns.TestRecord required
The failure.
glyphs ConsoleMonster.Glyphs.IGlyphSet required
The glyph set.

Returns

string The line (plain text).
public static List<StyledLine> FailureLines(TestRecord record, RenderContext context, int messageLines = 3) #

The lines of one failure: the symbol and path, expected and actual (the characters of the actual value that differ are underlined) or up to messageLines lines of the message, and the location as a link.

Parameters

record ConsoleMonster.TestRuns.TestRecord required
The failure.
context ConsoleMonster.Canvas.RenderContext required
The render context.
messageLines int = 3 optional
The most message lines to show.

Returns

List<StyledLine> The lines.
public static bool Heartbeat(ProgressHeartbeat heartbeat, TestRunSnapshot snapshot, IGlyphSet glyphs) #

Writes a heartbeat line for a run in append-only output when one is due: the tests done of the total and the problems so far (Tests: 120/450 (26%) · 3 failed · 1 errored · 01:12).

Parameters

heartbeat ConsoleMonster.ProgressHeartbeat required
The heartbeat (it decides when a line is due).
snapshot ConsoleMonster.TestRuns.TestRunSnapshot required
The run now.
glyphs ConsoleMonster.Glyphs.IGlyphSet required
The glyph set of the separators.

Returns

bool Whether a line was written.
public static string? Location(TestRecord record) #

The location as "file:line" (the file name only), or null when the file is unknown.

Parameters

record ConsoleMonster.TestRuns.TestRecord required
The record.

Returns

string? The text.
public static string Outcome(StatusKind status) #

The outcome words for a run status (Tests failed, Tests with errors, Tests to investigate, Tests inconclusive, Tests passed), translated.

Parameters

status ConsoleMonster.Styling.StatusKind required
The run status.

Returns

string The words.
public static string Path(IReadOnlyList<string> blocks, string name, IGlyphSet glyphs) #

The blocks and the test name joined by the breadcrumb separator (› or >).

Parameters

blocks System.Collections.Generic.IReadOnlyList<string> required
The blocks.
name string required
The test name.
glyphs ConsoleMonster.Glyphs.IGlyphSet required
The glyph set.

Returns

string The path.
public static string SummaryLine(TestRunSnapshot snapshot, IGlyphSet glyphs) #

The closing line for stream output: the status symbol, the outcome and the totals.

Parameters

snapshot ConsoleMonster.TestRuns.TestRunSnapshot required
The snapshot.
glyphs ConsoleMonster.Glyphs.IGlyphSet required
The glyph set.

Returns

string The line (plain text).
public static string Totals(TestRunSnapshot snapshot, IGlyphSet glyphs, bool clock = true) #

The run totals: "3 failed · 3 passed · 1 skipped · 7 tests · 00:00:01" (separators per tier).

Parameters

snapshot ConsoleMonster.TestRuns.TestRunSnapshot required
The snapshot.
glyphs ConsoleMonster.Glyphs.IGlyphSet required
The glyph set.
clock bool = true optional
Whether to end with the run clock.

Returns

string The facts.
public static bool TryParseExpectation(string? message, out string expected, out string actual) #

Reads expected and actual values from an assertion message ("Expected 4, but got 3.", or the "Expected:" and "But was:" lines of a string comparison). Quotes around both values are removed.

Parameters

message string? required
The message.
expected string required
The expected value.
actual string required
The actual value.

Returns

bool Whether both were found.