microsoft / microsoft/testfx

[test-improver] Add unit tests for RetryExtensions.AddRetryProvider

Open
#11,368 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/mtp-retry needs/triage
Dominant language
C#
Stars
1k
Forks
312
Avg merge
8h 30m
Merged PRs (30d)
469

Description

Goal and rationale

RetryExtensions.AddRetryProvider — the public entry point that wires the entire retry-failed-tests feature onto an ITestApplicationBuilder (command-line options provider, test-host application lifetime callback, data consumer/test session lifetime handler, and test-host orchestrator) — had zero direct test coverage. All existing Retry-area test files (RetryTests, RetryDataConsumerTests, RetryArgumentsBuilderTests, RetryOrchestratorHelperTests) construct the individual extension classes directly and never exercise this wiring method itself.

Approach

Added RetryExtensionsTests.cs with 3 tests using a real ITestApplicationBuilder (via TestApplication.CreateBuilderAsync):

  1. Verifies the retry command-line options provider is discoverable end-to-end via CommandLineManager.BuildAsync.
  2. Verifies exactly one test-host orchestrator factory is registered (via reflection on the internal _factories list, following the repo's established pattern for internal-state assertions).
  3. Verifies the test-host application lifetime callback, data consumer, and test session lifetime handler are all registered, and that the data consumer / test session lifetime handler share the same composite-registered RetryDataConsumer singleton instance — mirroring the real TestHostBuilder build pipeline (lifecycle callbacks registered into the service provider before data consumers are built; the same alreadyBuiltServices list shared across both composite-extension build calls).

Test Status

  • ./build.sh -restore succeeded.
  • dotnet build test/UnitTests/Microsoft.Testing.Extensions.UnitTests/Microsoft.Testing.Extensions.UnitTests.csproj -c Debug -f net8.0: 0 warnings, 0 errors.
  • Targeted run (--filter "FullyQualifiedName~RetryExtensionsTests"): 3/3 passed.
  • Full Microsoft.Testing.Extensions.UnitTests suite (net8.0): 1879 total, 1842 succeeded, 0 failed, 37 skipped (pre-existing) — no regressions.
  • dotnet format whitespace TestFx.slnx --verify-no-changes --include <file>: clean (only the expected harmless F#-project warning).

Reproducibility

./build.sh -restore
export PATH="$PWD/.dotnet:$PATH"
dotnet build test/UnitTests/Microsoft.Testing.Extensions.UnitTests/Microsoft.Testing.Extensions.UnitTests.csproj -c Debug -f net8.0
./artifacts/bin/Microsoft.Testing.Extensions.UnitTests/Debug/net8.0/Microsoft.Testing.Extensions.UnitTests --filter "FullyQualifiedName~RetryExtensionsTests"

Trade-offs

Two of the three tests reach into internal implementation details via casts to internal platform types (CommandLineManager, TestHostManager, TestHostOrchestratorManager) and one reflection-based field read (_factories), following the established pattern used throughout this test project (IVT-granted internal type casts + reflection for otherwise-unobservable internal state). This ties the tests to internal structure, but is consistent with how the rest of the Microsoft.Testing.Extensions.UnitTests project already tests similar wiring extension methods.


[!NOTE]
This was originally intended as a pull request, but the git push operation failed.

Original error: The process '/usr/bin/git' failed with exit code 128

Workflow Run: View run details and download bundle artifact

The bundle file is available in the agent artifact in the workflow run linked above.

Create the pull request manually
# Download the artifact from the workflow run
gh run download '35284383111' -n agent -D '/tmp/agent-35284383111'

# Resolve the bundle source ref, fetch it into a temporary ref, then create the local branch
bundle_path='/tmp/agent-35284383111/aw-test-assist-retry-extensions-tests.bundle'
temp_ref='refs/bundles/create-pr-test-assist-retry-extensions-tests-396ff906fef91010-0880482b'
target_ref='refs/heads/test-assist/retry-extensions-tests-396ff906fef91010'
bundle_source_ref=$(git bundle list-heads "$bundle_path" | awk '$2 ~ /^refs\/heads\// { print $2 }')
if [ -z "$bundle_source_ref" ]; then
  bundle_source_ref=$(git bundle list-heads "$bundle_path" | awk '$2 == "HEAD" { print $2 }')
fi
if [ "$(printf '%s\n' "$bundle_source_ref" | sed '/^$/d' | wc -l | tr -d ' ')" != "1" ]; then
  echo "Expected exactly one bundle source ref, found: $bundle_source_ref" >&2
  exit 1
fi
git fetch "$bundle_path" "${bundle_source_ref}:${temp_ref}"
git update-ref "$target_ref" "$temp_ref"
git checkout 'test-assist/retry-extensions-tests-396ff906fef91010'
# Ensure the working tree matches the updated branch
git reset --hard
# Remove the temporary bundle ref
git update-ref -d "$temp_ref"

# Push the branch to the target remote
git push 'origin' 'test-assist/retry-extensions-tests-396ff906fef91010'

# Create the pull request
gh pr create --title '[test-improver] Add unit tests for RetryExtensions.AddRetryProvider' --base 'main' --head 'test-assist/retry-extensions-tests-396ff906fef91010' --repo 'microsoft/testfx'

[!WARNING]

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • github.com
  • southcentralus0.in.applicationinsights.azure.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"
    - "southcentralus0.in.applicationinsights.azure.com"

See Network Configuration for more information.

🤖 Automated content by GitHub Copilot. Generated by the Test Improver workflow. · copilot · auto · 661.5 AIC · ⌖ 13.3 AIC · ⊞ 16.8K · [◷]( · )
Comment /test-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/test-improver.md@main

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at RetryExtensions.AddRetryProvider and review the existing RetryTests, RetryDataConsumerTests, RetryArgumentsBuilderTests, and RetryOrchestratorHelperTests before creating RetryExtensionsTests.cs. Run the targeted Microsoft.Testing.Extensions.UnitTests command with the RetryExtensionsTests filter; done means the three wiring tests pass without regressions in the broader unit-test suite.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.