Skip to content

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

Description

@nohwnd-bot

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions