dotnet / dotnet/command-line-api
[main] Test has incorrect errors for `-x 1 2 3 4`
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
[The test I used to confirm unexpected behavior](https://github.com/dotnet/command-line-api/blob/963d34b1fb712c673bfb198133d7e988182c9ef4/src/System.CommandLine.Tests/ParserTests.cs#L1550)
The test is:
```csharp
[Fact]
public void When_option_arguments_are_greater_than_maximum_arity_then_an_error_is_returned()
{
var command = new CliCommand("the-command")
{
new CliOption("-x") { Arity = new ArgumentArity(2, 3)}
};
var parseResult = CliParser.Parse(command, "-x 1 2 3 4");
parseResult.Errors
.Select(e => e.Message)
.Should()
.Contain(LocalizationResources.UnrecognizedCommandOrArgument("4"));
}
```
I modified the test only to get an interim variable for `parseResult`,
When I do this, the error list is

I encountered this because for Powderhouse I encountered issues with options with collection types and I believe I am using the same or funcionally equivalent code - and this test passes. In exploring why my new tests were failing, I realized this test does not appear to be succeeding at what the CLI and the commandline request.
I believe this test should result in a single parse error - an unexpected argument only on the 4.
Contributor guide
Assessment
This issue has not been assessed yet.