Skip to content

Add Aspire.Hosting.Maui.Tests to CI and expand test coverage#14768

Open
jfversluis wants to merge 1 commit intodotnet:mainfrom
jfversluis:maui-test-coverage
Open

Add Aspire.Hosting.Maui.Tests to CI and expand test coverage#14768
jfversluis wants to merge 1 commit intodotnet:mainfrom
jfversluis:maui-test-coverage

Conversation

@jfversluis
Copy link
Member

Summary

\Aspire.Hosting.Maui.Tests\ has never run in CI — it was only included in a dynamically generated \AspireWithMaui.slnx\ created by
estore.cmd -mauirestore, which no CI workflow references. This PR fixes that and adds comprehensive test coverage.

Changes

Enable existing tests in CI

  • Add \Aspire.Hosting.Maui.Tests\ to \Aspire.slnx\ in /tests/Hosting/\ folder
  • All 72 existing tests are pure unit tests (no MAUI workload needed) and pass on all platforms

Add 60 new tests covering previously untested areas

Test file Tests Coverage area
\MauiProjectResourceValidationTests.cs\ 7 \AddMauiProject\ null/empty arg validation, ProjectPath, resource visibility
\MauiWithArgsTests.cs\ 11 \dotnet run\ CLI args per platform (TFM, AdbTarget, _DeviceName, RuntimeIdentifier, OpenArguments)
\MauiEnvironmentHelperTests.cs\ 12 Android/iOS MSBuild targets XML generation, \EncodeSemicolons, \SanitizeFileName\
\MauiUnsupportedPlatformTests.cs\ 7 \UnsupportedPlatformAnnotation\ present/absent per OS
\MauiiOSValidationTests.cs\ 6 iOS device/simulator UDID cross-validation (GUID vs non-GUID format)
\MauiOtlpTemplateTests.cs\ 9 OTLP env vars don't contain {{\ DCP template placeholders

Production code change

  • 4 \private\ methods in \MauiEnvironmentHelper\ changed to \internal\ for testability (\GenerateAndroidTargetsFileContent, \GenerateiOSTargetsFileContent, \EncodeSemicolons, \SanitizeFileName). The class itself is already \internal\ and \InternalsVisibleTo\ was pre-existing.

Test results

\
total: 132, failed: 0, succeeded: 131, skipped: 1
\\

The 1 skipped test is \WindowsDevice_OnNonWindows_HasUnsupportedPlatformAnnotation\ which correctly skips on Windows (uses \Assert.Skip).

Copilot AI review requested due to automatic review settings February 27, 2026 13:01
@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14768

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14768"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables the Aspire.Hosting.Maui.Tests project in CI and adds comprehensive test coverage (60 new tests) for previously untested MAUI hosting functionality. The tests cover critical areas including input validation, platform-specific arguments, environment variable handling, iOS device/simulator UDID validation, platform support detection, and OTLP configuration.

Changes:

  • Added Aspire.Hosting.Maui.Tests to Aspire.slnx to enable CI execution of 72 existing + 60 new unit tests
  • Added 60 new tests covering AddMauiProject validation, CLI argument generation per platform, environment helper methods, iOS UDID cross-validation, platform support annotations, and OTLP template resolution
  • Changed 4 private methods in MauiEnvironmentHelper to internal for testability (class already internal with InternalsVisibleTo)

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Aspire.slnx Added Aspire.Hosting.Maui.Tests project to tests/Hosting/ folder in solution to enable CI execution
src/Aspire.Hosting.Maui/Utilities/MauiEnvironmentHelper.cs Changed 4 methods from private to internal for testability: GenerateAndroidTargetsFileContent, GenerateiOSTargetsFileContent, EncodeSemicolons, SanitizeFileName
tests/Aspire.Hosting.Maui.Tests/MauiProjectResourceValidationTests.cs Added 7 tests validating AddMauiProject null/empty arguments, ProjectPath property, resource name, and resource visibility in AppModel
tests/Aspire.Hosting.Maui.Tests/MauiWithArgsTests.cs Added 11 tests verifying dotnet run CLI arguments per platform (TFM, AdbTarget, RuntimeIdentifier, _DeviceName, OpenArguments)
tests/Aspire.Hosting.Maui.Tests/MauiEnvironmentHelperTests.cs Added 12 tests for Android/iOS MSBuild targets XML generation, EncodeSemicolons, and SanitizeFileName utility methods
tests/Aspire.Hosting.Maui.Tests/MauiUnsupportedPlatformTests.cs Added 7 tests verifying UnsupportedPlatformAnnotation presence/absence per OS (Windows, macOS, Android, iOS)
tests/Aspire.Hosting.Maui.Tests/MauiiOSValidationTests.cs Added 6 tests for iOS device/simulator UDID cross-validation (GUID vs non-GUID format detection)
tests/Aspire.Hosting.Maui.Tests/MauiOtlpTemplateTests.cs Added 9 tests ensuring OTLP environment variables don't contain DCP template placeholders ({{...}}) after evaluation

- Add Aspire.Hosting.Maui.Tests to Aspire.slnx so tests run in CI
  (72 existing tests were never included in the main solution)
- Add 60 new tests covering previously untested areas:
  - AddMauiProject input validation and resource creation
  - Command-line args per platform (TFM, AdbTarget, _DeviceName, RuntimeIdentifier)
  - MauiEnvironmentHelper utilities (targets XML, EncodeSemicolons, SanitizeFileName)
  - UnsupportedPlatformAnnotation on unsupported OS
  - iOS device/simulator ID cross-validation (GUID vs non-GUID)
  - OTLP template placeholder replacement (no {{ DCP templates in env vars)
- Change 4 private methods in MauiEnvironmentHelper to internal for testability

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.

2 participants