Skip to content

[Test Improver] Add unit tests for ResponseFileHelper.SplitCommandLine #8274

@Evangelink

Description

@Evangelink

🤖 Test Improver — automated AI assistant

Goal and Rationale

ResponseFileHelper.SplitCommandLine is a custom command-line tokenizer (state machine with ~90 lines of logic) adapted from dotnet/command-line-api. It handles quoted strings, whitespace separators, and quote removal. Despite being a complex parser, it had no dedicated unit tests.

Approach

Added 12 focused unit tests in ResponseFileHelperTests.cs covering:

Test What it verifies
EmptyString_ReturnsNoTokens Empty input produces no tokens
WhitespaceOnly_ReturnsNoTokens Whitespace-only input produces no tokens
SingleWord_ReturnsThatWord Basic single-word case
MultipleWords_ReturnsAllWords Space-separated words
MultipleSpacesBetweenWords_ReturnsAllWords Multiple spaces are collapsed
QuotedStringWithSpaces_ReturnsSingleToken Quoted spaces don't split tokens
QuotedAndUnquotedTokens_ReturnsBothTokens Mixed tokens work
QuotesRemovedFromToken Quote characters are stripped
LeadingAndTrailingSpaces_IgnoresSpaces Trim behavior
TabSeparatedWords_ReturnsAllWords Tab whitespace splitting
QuotedStringContainingTab_ReturnsSingleToken Tabs inside quotes not split
TypicalResponseFileLine_ReturnsExpectedTokens Realistic .rsp file line

Test Status

✅ 24 test executions pass (12 tests × net8.0 + net9.0)
✅ Build clean with -p:TreatWarningsAsErrors=true

Reproducibility

dotnet test test/UnitTests/Microsoft.Testing.Platform.UnitTests/Microsoft.Testing.Platform.UnitTests.csproj -c Debug --filter "ResponseFileHelper"

Generated by Daily Test Improver · ● 8.3M ·


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 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 25955175549 -n agent -D /tmp/agent-25955175549

# Fetch the bundle into a local branch
git fetch /tmp/agent-25955175549/aw-test-assist-response-file-helper-tests.bundle refs/heads/test-assist/response-file-helper-tests:refs/heads/test-assist/response-file-helper-tests-4a66faf9e4584357
git checkout test-assist/response-file-helper-tests-4a66faf9e4584357

# Push the branch to origin
git push origin test-assist/response-file-helper-tests-4a66faf9e4584357

# Create the pull request
gh pr create --title '[Test Improver] Add unit tests for ResponseFileHelper.SplitCommandLine' --base main --head test-assist/response-file-helper-tests-4a66faf9e4584357 --repo microsoft/testfx

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions