Skip to content

[Test Improver] Add unit tests for CommandLineOption#8319

Merged
Evangelink merged 4 commits into
mainfrom
test-assist/command-line-option-tests-287cfe29f0af8b9e
May 18, 2026
Merged

[Test Improver] Add unit tests for CommandLineOption#8319
Evangelink merged 4 commits into
mainfrom
test-assist/command-line-option-tests-287cfe29f0af8b9e

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Tests cover constructor validation (null/empty/whitespace name and description,
invalid arity, invalid characters in name), property initialization, equality
(Equals/GetHashCode) for same and differing values.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Fix #8310

Tests cover constructor validation (null/empty/whitespace name and description,
invalid arity, invalid characters in name), property initialization, equality
(Equals/GetHashCode) for same and differing values.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 18, 2026 11:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new unit test file CommandLineOptionTests.cs covering constructor validation, property initialization, equality, and hash code behavior of the public CommandLineOption class in Microsoft.Testing.Platform.

Changes:

  • Adds 26 MSTest test methods (some [DataRow]-driven) for CommandLineOption constructor argument validation (null/empty/whitespace name & description, invalid arity, invalid name characters).
  • Adds tests for valid name characters, property assignment, and IsHidden handling.
  • Adds tests for Equals (typed and object overloads, including null) and GetHashCode behavior.
Show a summary per file
File Description
test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/CommandLineOptionTests.cs New unit test file exercising CommandLineOption constructor validation, property initialization, equality, and hashing.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

Copy link
Copy Markdown
Member Author

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Dimension Verdict
1 Algorithmic Correctness 🟠 1 MODERATE
10 Test Isolation / Assertion Quality 🔵 1 NIT

✅ 19/21 dimensions clean.

  • Algorithmic Correctness — GetHashCode_DifferentValues_ReturnsDifferentHash asserts hash uniqueness, which is not part of the GetHashCode contract and is coincidentally true rather than contractually guaranteed.
  • Test Coverage — whitespace description guard is tested for name (3 variants) but only 2 variants for description; Ensure.NotNullOrWhiteSpace(description) should also reject whitespace.

Everything else looks solid: the tests are well-structured, follow the project's Assert.* naming conventions, cover null/empty/invalid-char/valid-char scenarios, and correctly verify both Equals(T) and Equals(object) overloads.

Generated by Expert Code Review (on open) for issue #8319 · ● 6.6M

@Evangelink
Copy link
Copy Markdown
Member Author

@copilot address review comments

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

@copilot address review comments

Addressed the review comments in commit 3c6743b.

Copilot AI review requested due to automatic review settings May 18, 2026 13:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new

@Evangelink Evangelink merged commit 67e7f7d into main May 18, 2026
17 checks passed
@Evangelink Evangelink deleted the test-assist/command-line-option-tests-287cfe29f0af8b9e branch May 18, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Test Improver] Add unit tests for CommandLineOption

4 participants