Skip to content
ConsoleMonster
Class

GoldenFile

ConsoleMonster.Testing

Namespace
ConsoleMonster.Testing
Assembly
ConsoleMonster
Modifiers
static

Snapshot ("golden file") comparison for console output. The first run writes the file and fails so it gets reviewed; later runs compare and fail with a readable diff (the first differing line with context, both versions, and the column where they part). Set CONSOLEMONSTER_UPDATE_GOLDEN=1 to rewrite the files after an intended change. Line endings are normalised to \n; files are UTF-8 without a byte order mark.

Inheritance

  • object
  • GoldenFile

Methods

public static string Diff(string path, string expected, string actual) #

A readable description of where two texts differ.

Parameters

path string required
The golden file (for the message).
expected string required
The golden text.
actual string required
The text produced now.

Returns

string The description.
public static void Match(string path, string actual) #

Compares text with a golden file; throws GoldenFileMismatchException when they differ.

Parameters

path string required
The golden file.
actual string required
The text produced now.

Properties

public static bool Updating { get; } #

Whether golden files are being rewritten in this process.

Fields

public const string UpdateVariable #

The environment variable that rewrites golden files instead of comparing.

Value: CONSOLEMONSTER_UPDATE_GOLDEN