Skip to content

Unit tests for command/option parsing correctness in CLI app? #2552

Closed Answered by jonsequitur
ptr727 asked this question in Q&A
Discussion options

You must be logged in to vote

By calling ParseResult.GetValue (renamed in beta5 from GetValueForArgument / GetValueForOption), you can check the parsed value of any option or argument.

You can see lots of usage examples in these tests:

https://github.com/dotnet/command-line-api/blob/060374e56c1b2e741b6525ca8417006efb54fbd7/src/System.CommandLine.Tests/GetValueByNameParserTests.cs

https://github.com/dotnet/command-line-api/blob/e8282e765515d32c96ea6adb2ec83653ed1379a5/src/System.CommandLine.Tests/Binding/TypeConversionTests.cs

Re no built-in binding support in beta 5, what does that mean?

This refers to the functionality in earlier versions that allowed System.CommandLine to create an instance of a class with propert…

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@ptr727
Comment options

@jonsequitur
Comment options

@ptr727
Comment options

@jonsequitur
Comment options

Answer selected by ptr727
@ptr727
Comment options

@jonsequitur
Comment options

@ptr727
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants