Skip to content

[Test Improver] Add unit tests for PasteArguments.AppendArgument - #7888

Merged
Evangelink merged 2 commits into
mainfrom
test-assist/paste-arguments-tests-43643589db600b79
Apr 29, 2026
Merged

[Test Improver] Add unit tests for PasteArguments.AppendArgument#7888
Evangelink merged 2 commits into
mainfrom
test-assist/paste-arguments-tests-43643589db600b79

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Covers argument escaping edge cases: simple args, empty string, spaces, tabs, quotes, backslash-at-end (doubling), backslash-before-quote (2N+1 rule), multiple args with separator, and path-with-spaces.

Fixes #7879

Covers argument escaping edge cases: simple args, empty string, spaces,
tabs, quotes, backslash-at-end (doubling), backslash-before-quote
(2N+1 rule), multiple args with separator, and path-with-spaces.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 28, 2026 06:58
@Evangelink
Evangelink enabled auto-merge (squash) April 28, 2026 06:58

@Youssef1313 Youssef1313 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds targeted unit test coverage for Microsoft.Testing.Platform.Helpers.PasteArguments.AppendArgument, a Windows command-line argument escaping utility used when building process command lines.

Changes:

  • Introduces a new PasteArgumentsTests test class with scenarios covering quoting/escaping rules for whitespace, quotes, and backslashes.
  • Adds multi-argument composition tests to validate separator insertion and end-to-end command line output.
Show a summary per file
File Description
test/UnitTests/Microsoft.Testing.Platform.UnitTests/Helpers/PasteArgumentsTests.cs Adds unit tests covering key escaping/quoting edge cases for PasteArguments.AppendArgument.

Copilot's findings

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

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

Workflow: Test Expert Reviewer 🧪
Date: 2026-04-28
Repository: microsoft/testfx

Key Findings

  • [Coverage – Medium] char.IsWhiteSpace covers '\n', '\r', '\v', '\f' in addition to space and tab, but only space (' ') and tab ('\t') are tested. A regression replacing the char.IsWhiteSpace check with an explicit set would go undetected.
  • [Coverage – Low] The separator-space logic is only tested with two simple unquoted arguments; second-call behaviour with empty-string or space-containing arguments is untested.
  • [DataDriven – Minor] The 15 individual [TestMethod] tests could be consolidated into a smaller set of parameterised tests using [DataRow], improving discoverability of coverage gaps.

What's Good

  • Every test uses a fresh local StringBuilder — no shared mutable state, no isolation risk.
  • Assertions use Assert.AreEqual throughout, giving clear actual-vs-expected failure output.
  • All significant backslash-escaping rules (end-of-arg doubling, 2N+1 rule before quote) are covered with concrete examples.
  • No timing dependencies, no I/O, no environment sensitivity.

Recommendations

  1. Add [DataRow]/[TestMethod] entries for '\n' and '\r' in the "wraps in quotes" tests.
  2. Add a test verifying the separator appears before complex (empty or space-containing) second arguments.
  3. Consider consolidating similar tests with [DataRow] to make coverage gaps more visible.

Generated by Test Expert Reviewer 🧪

🧪 Test quality reviewed by Test Expert Reviewer 🧪

@Evangelink

Copy link
Copy Markdown
Member Author

…net/runtime reference

Agent-Logs-Url: https://github.com/microsoft/testfx/sessions/4f3cd68a-ca2f-4d93-8488-e84abbb91a1b

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

Copilot AI commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Consider: https://github.com/dotnet/runtime/blob/3ac6e13b2780bbaf03c62488fced60b9a76e9782/src/libraries/Common/tests/Tests/System/PasteArgumentsTests.cs

@copilot please use the use cases and stru...

Done in 60c5a5d. Replaced the individual [TestMethod] tests with a single data-driven [DataTestMethod] Pastes test using the same 6 [DataRow] cases as the reference (simple args, app name with spaces, double backslash, literal quote, 2N+1 backslashes-before-quote rule, and 2N backslashes-before-quote rule).

@Evangelink
Evangelink disabled auto-merge April 29, 2026 09:10
@Evangelink
Evangelink merged commit 1a87291 into main Apr 29, 2026
24 checks passed
@Evangelink
Evangelink deleted the test-assist/paste-arguments-tests-43643589db600b79 branch April 29, 2026 09:10
Evangelink added a commit that referenced this pull request May 12, 2026
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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 PasteArguments.AppendArgument

4 participants