Runic.CommandLine.Testing 0.7.0-preview.2

This is a prerelease version of Runic.CommandLine.Testing.
dotnet add package Runic.CommandLine.Testing --version 0.7.0-preview.2
                    
NuGet\Install-Package Runic.CommandLine.Testing -Version 0.7.0-preview.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Runic.CommandLine.Testing" Version="0.7.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Runic.CommandLine.Testing" Version="0.7.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="Runic.CommandLine.Testing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Runic.CommandLine.Testing --version 0.7.0-preview.2
                    
#r "nuget: Runic.CommandLine.Testing, 0.7.0-preview.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Runic.CommandLine.Testing@0.7.0-preview.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Runic.CommandLine.Testing&version=0.7.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Runic.CommandLine.Testing&version=0.7.0-preview.2&prerelease
                    
Install as a Cake Tool

Runic.CommandLine.Testing

Use this package in tests for deterministic command invocation fixtures. It provides an in-memory console, a simple scope factory, parsed invocations, captured parse settings, an already-cancelled token, and JSON envelope parsing without reading or mutating process-global state.

Test the whole application

var tester = new CommandAppTester(console => new CommandApp(catalog)
{
    Console = console,
    ParseSettings = ParseSettings.Default,
    HandleCancelKeyPress = false,
});
var result = await tester.RunAsync(["greet", "Ada", "--output=json"]);
using var frame = CommandTestEnvelope.Parse(result.StandardOutput);

For prompt tests, construct TestCommandConsole with explicit capability flags and call QueueInput. Each tester run gets fresh output buffers.

Test a continuation

Run is the synchronous counterpart of RunAsync. It runs the application with CommandApp.Run, so a command that hands a continuation back with CommandExecutionContext.ContinueOnCallingThread has it run on the thread that calls Run:

CommandAppTestResult result = tester.Run(["ui", "--no-open"]);

ExitCode is the continuation's result, or the invocation's exit code when it failed or handed nothing back. StandardOutput and StandardError are captured after the continuation returned. Call it from a test that does not hold a SynchronizationContext the handler depends on; the invocation itself runs without one.

Script prompt answers

CommandPrompts reads one line per prompt from an interactive TestCommandConsole. Supply the console through CreateConsole:

var tester = new CommandAppTester(console => new CommandApp(catalog) { Console = console, ParseSettings = ParseSettings.Default })
{
    CreateConsole = () =>
    {
        var console = new TestCommandConsole { IsInteractive = true };
        console.QueueInput("2");      // the second choice of a select, or its label
        console.QueueInput("y");      // a confirm
        return console;
    },
};

A queued null is the end of input, which cancels the command (exit code 4). The default noninteractive console never asks: prompts return their defaults or fail with RCLI4001. To drive the redrawn terminal prompts, set SupportsAnsi = true (with SupportsUnicode and Width as needed) and queue keys with QueueKey(ConsoleKey.DownArrow), QueueKey(ConsoleKey.Enter) or QueueText("name\n"). Their frames, ANSI sequences included, are captured in StandardError. ReadKeyAsync waits until a key is queued or the token is cancelled, which lets a test cancel a waiting prompt. Keep a reference to the console you create and check PendingInputCount and PendingKeyCount to make sure every queued answer was used.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.0-preview.2 76 10/17/2026
0.7.0-preview.1 275 10/14/2026
0.6.0-preview.5 157 10/12/2026
0.6.0-preview.4 60 10/12/2026
0.6.0-preview.3 176 10/9/2026
0.6.0-preview.2 85 10/7/2026
0.6.0-preview.1 105 10/5/2026
0.5.0-preview.3 56 10/1/2026
0.5.0-preview.2 67 9/25/2026
0.4.0-preview.1 63 9/22/2026
0.3.0-preview.1 73 9/11/2026
0.2.0-preview.1 81 9/9/2026