Omit empty description from help output - #2842
Conversation
|
|
||
| public static AndConstraint<StringAssertions> ShowHelp(this StringAssertions output) => | ||
| output.Subject.Should().Match("*Description:*Usage:*"); | ||
| output.Subject.Should().Match("*Usage:*Options:*"); |
There was a problem hiding this comment.
This change potentially affects many tests and could allow regressions in the tested behavior. I'd recommend putting the assertion directly in the new tests for this specific case rather than changing an existing assertion helper.
There was a problem hiding this comment.
Good point. I removed the shared ShowHelp/NotShowHelp helpers and replaced their six call sites with direct assertions tailored to each test. The new regression also verifies that Usage remains present when Description is omitted.
There was a problem hiding this comment.
This still subtly changes the intent of the existing tests and could lead to other possible regressions (e.g. .Contains("--help") could pass if there's a parsing error that results in help being displayed... and that might be an issue that exists before your PR, so maybe ShowHelp should also ideally contain an error check).
Ideally, ShowHelp (the naming of which makes the intent very clear) should be updated to definitively determine that help was shown, without relying on circumstantial evidence, but I think this kind of test design change is probably out of scope for a pretty simple bug fix.
Replace shared help assertions with direct checks at their call sites. Do not use optional help sections as a proxy for help output. Signed-off-by: subotac <73706465+subotac@users.noreply.github.com>
@dotnet-policy-service agree |
Summary
Fixes #2114
Testing