You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CommandLineOption is a public API class with non-trivial validation logic in its constructor: it validates name/description for null/whitespace, enforces arity constraints (Max ≥ Min), and rejects names with characters outside [a-zA-Z0-9-?]. It also implements IEquatable<CommandLineOption> with a custom GetHashCode. Despite being a fundamental building block for all CLI extension authors, it had no dedicated unit tests.
Approach
Added CommandLineOptionTests.cs with 26 test cases (52 total across net8.0 + net9.0) covering:
Category
Tests
Valid construction
Properties set correctly, IsHidden set correctly
null name/description
ArgumentNullException thrown
Empty/whitespace name/description
ArgumentException thrown
Invalid arity (Max < Min)
ArgumentException thrown
Name with invalid characters (!, @, space, etc.)
ArgumentException thrown via [DataRow]
Name with valid characters (opt, my-option, ?, etc.)
The bundle file is available in the agent artifact in the workflow run linked above.
To create a pull request with the changes:
# Download the artifact from the workflow run
gh run download 26018812150 -n agent -D /tmp/agent-26018812150
# Fetch the bundle into a local branch
git fetch /tmp/agent-26018812150/aw-test-assist-command-line-option-tests.bundle refs/heads/test-assist/command-line-option-tests:refs/heads/test-assist/command-line-option-tests-287cfe29f0af8b9e
git checkout test-assist/command-line-option-tests-287cfe29f0af8b9e
# Push the branch to origin
git push origin test-assist/command-line-option-tests-287cfe29f0af8b9e
# Create the pull request
gh pr create --title '[Test Improver] Add unit tests for CommandLineOption' --base main --head test-assist/command-line-option-tests-287cfe29f0af8b9e --repo microsoft/testfx
🤖 Test Improver — automated AI assistant
Goal and Rationale
CommandLineOptionis a public API class with non-trivial validation logic in its constructor: it validates name/description for null/whitespace, enforces arity constraints (Max ≥ Min), and rejects names with characters outside[a-zA-Z0-9-?]. It also implementsIEquatable<CommandLineOption>with a customGetHashCode. Despite being a fundamental building block for all CLI extension authors, it had no dedicated unit tests.Approach
Added
CommandLineOptionTests.cswith 26 test cases (52 total across net8.0 + net9.0) covering:IsHiddenset correctlynullname/descriptionArgumentNullExceptionthrownArgumentExceptionthrownArgumentExceptionthrown!,@, space, etc.)ArgumentExceptionthrown via[DataRow]opt,my-option,?, etc.)Equals— matching valuestrue(typed + object overloads)Equals— differing name/description/arity/isHiddenfalseEquals— nullfalseGetHashCode— same valuesGetHashCode— different valuesTest Status
✅ All 52 test executions pass (26 tests × net8.0 + net9.0)
Reproducibility
Note
This was originally intended as a pull request, but the git push operation failed.
Workflow Run: View run details and download bundle artifact
The bundle file is available in the
agentartifact in the workflow run linked above.To create a pull request with the changes: