Skip to content

Add dotnet test device selection support for MAUI#54295

Draft
jonathanpeppers wants to merge 1 commit into
mainfrom
jonathanpeppers/maui-spec-dotnet-test
Draft

Add dotnet test device selection support for MAUI#54295
jonathanpeppers wants to merge 1 commit into
mainfrom
jonathanpeppers/maui-spec-dotnet-test

Conversation

@jonathanpeppers
Copy link
Copy Markdown
Member

Summary

Adds --device and --interactive options to dotnet test (MTP path) for .NET MAUI projects, enabling per-target-framework device selection.

Behavior

  • Default: dotnet test iterates all target frameworks without prompting (existing behavior unchanged)
  • Per-TFM device prompting: For each TFM, if ComputeAvailableDevices target exists, uses RunCommandSelector to handle device selection
  • --device: When specified without -f, forces a target framework prompt since devices are platform-specific
  • Non-interactive: Errors with a helpful message when prompting would be required but stdin is redirected / CI

Changes

  • TestCommandDefinition.MicrosoftTestingPlatform.cs — Added DeviceOption and InteractiveOption
  • Options.cs / MSBuildUtility.csDevice and IsInteractive on BuildOptions
  • MicrosoftTestingPlatformTestCommand.csHandleDeviceWithTargetFrameworkSelection() for --device + TF selection
  • SolutionAndProjectUtility.csTrySelectDeviceForProject() called per-TFM before running tests
  • dotnet-run-for-maui.md — Updated spec with dotnet test behavior section

Tests

7 integration tests in GivenDotnetTestSelectsDevice covering:

  • Non-interactive failure with multiple devices
  • Specified device (2 variants)
  • Auto-select single device
  • TF prompt with --device in non-interactive mode
  • Combined -f + --device
  • Projects without ComputeAvailableDevices target

Update dotnet-run-for-maui.md spec with dotnet test behavior section.

Add --device and --interactive options to dotnet test (MTP path).
When --device is specified without -f, prompt for target framework
selection since devices are platform-specific. For each TFM, check
for ComputeAvailableDevices target and use RunCommandSelector to
handle device selection (auto-select single device, error in
non-interactive mode with multiple devices).

Includes DotnetTestDevices test asset and 7 integration tests.

Co-authored-by: Copilot <223556219+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.

1 participant