Skip to content
ConsoleMonster

API Reference

Class

GoldenFile

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) #
Returns: String

A readable description of where two texts differ.

Parameters

path System.String requiredposition: 0
The golden file (for the message).
expected System.String requiredposition: 1
The golden text.
actual System.String requiredposition: 2
The text produced now.

Returns

The description.

public static Void Match(String path, String actual) #
Returns: Void

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

Parameters

path System.String requiredposition: 0
The golden file.
actual System.String requiredposition: 1
The text produced now.

Properties

public static Boolean 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