--- name: "spectre-cli-help-assertions" description: "Write resilient assertions for Spectre.Console.Cli help output" domain: "testing" confidence: "high" source: "observed" --- ## Context Use this when testing CLI help output generated by Spectre.Console.Cli. The framework controls wrapping, spacing, and inline default-value formatting, so exact string matches are brittle across versions and environments. ## Patterns - Reproduce the real help output first by invoking the compiled CLI with no arguments or `--help`. - Assert the behavior contract, not the formatter details: - exit code is `0` - usage matches with whitespace-tolerant regex - expected sections such as `ARGUMENTS:` and `OPTIONS:` are present - one or more product-specific option names are present - Avoid asserting whole rendered lines when the same information can be checked semantically. ## Examples - `result.Output.Should().MatchRegex(@"USAGE:\s+refitter\s+\[URL or input file\]\s+\[OPTIONS\]");` - `result.Output.Should().Contain("ARGUMENTS:");` - `result.Output.Should().Contain("--generate-authentication-header");` ## Anti-Patterns - Matching the full usage/help block with exact spaces or line breaks. - Treating formatter-driven whitespace differences as product regressions.