Skip to content

[Testing] Launch UI fixtures directly instead of navigating through the gallery - #39621

Merged
kubaflo merged 5 commits into
mainfrom
kubaflo-issue-32463-fix
Oct 27, 2026
Merged

kubaflo merged 5 commits into
mainfrom
kubaflo-issue-32463-fix

Conversation

@kubaflo

@kubaflo kubaflo commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Extend the existing MacCatalyst startup-page resolver to Android, iOS, and Windows, and wire it into _IssuesUITest / _GalleryUITest so fixtures and resets can launch directly to their issue or gallery page instead of searching and tapping through the gallery.

  • Android, iOS, MacCatalyst: direct fixture launch is enabled by default. Driver sessions remain reusable; each fixture receives its own startup target. Reset/retry paths retain the current target, and teardown closes the app instead of launching an unused gallery. Gallery subpage selection still runs after launch; the current Android CoreCLR ShellSearch setup failure remains under investigation.
  • Windows: startup arguments and fixture integration are implemented, but direct fixture launch is opt-in with MAUI_UITEST_DIRECT_LAUNCH=true. WinAppDriver cannot change appArguments on an existing session, so changing targets requires a new session. Keep the existing navigation default until native timing proves this is a benefit.
  • Set MAUI_UITEST_DIRECT_LAUNCH=false to compare legacy navigation. Normal launches and missing/empty/unknown startup targets still open the gallery; unknown targets emit a debug diagnostic.
  • Preserve the internet-required issue check through the shared page factory. Forward the configured Android UDID to Appium and escape launch arguments.
  • Starting a new Apple test target and resetting the app stop explicitly when closing fails. Correction in 10e3dc7d710: OS-command fallbacks no longer return success for a missing process, timeout, or nonzero exit code; redirected output is drained and failures are logged. Reset checks the close result before relaunching. This closes the reproduced gap where a failed simctl terminate command was incorrectly reported as success.
  • Add startup/lifecycle utility tests to the solution and Helix unit-project list, plus cross-platform fixture/reset coverage. The regression page records how many application windows existed during construction: 0 demonstrates initial-page creation, while the legacy gallery-navigation control observes 1.

Manual startup examples (exact issue description or gallery title, case-insensitive):

adb shell am start -S -n com.microsoft.maui.uitests/com.microsoft.maui.uitests.MainActivity --es test '"Direct test launch"'
SIMCTL_CHILD_test="Direct test launch" xcrun simctl launch --terminate-running-process <simulator-udid> com.microsoft.maui.uitests
.\Controls.TestCases.HostApp.exe '--test=Direct test launch'

MacCatalyst continues using the app process's test environment variable. Startup arguments are consumed during initial-window creation; do not merely foreground an already-running process when changing targets. This extends #31673's resolver rather than adding a competing one.

Issues Fixed

Fixes #32463

Validation

Termination-fallback correction

  • dotnet test src/TestUtils/tests/UITest.Appium.Tests/UITest.Appium.Tests.csproj --filter 'FullyQualifiedName~FailedSimulatorFallbackCannotLaunchWithStaleStartupArguments' -v:minimal — both new cases failed before the fix with the intended missing-exception assertion. They use a recording driver that rejects termination and a real simctl command with an invalid simulator ID; no simulator app or host UI is controlled.
  • dotnet test src/TestUtils/tests/UITest.Appium.Tests/UITest.Appium.Tests.csproj --no-restore -v:minimal — 22 passed after the fix. Includes the original 19 utility tests, the two launch/reset regressions, and a direct force-close response regression.
  • dotnet test src/TestUtils/tests/UITest.Appium.Tests/UITest.Appium.Tests.csproj --no-build -v:q — 22 passed in each of two additional fresh test processes.

These utility tests establish the corrected fallback behavior, not native Appium reliability or resolution of the outstanding UI failures.

Earlier implementation validation

The following checks were performed during the initial implementation, before the later rebase onto 4781afbd. They were not rerun as native certification of 10e3dc7d710.

Initial iOS validation used an isolated iPhone 11 Pro on iOS 26.5 with simctl launches, screenshots, and local Vision OCR: all six startup scenarios passed 3/3 (18 checks). Subsequently, with explicit permission for simulator-only XCTest/WebDriverAgent, DEVICE_UDID=5668A696-15E3-41E8-884C-7D06EB167B07 dotnet test src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj --no-build --filter 'FullyQualifiedName~Issue32463Runner' ran the actual fixture: 2 passed, covering direct startup and tap/increment/reset. No host macOS UI automation was used. This does not clear the current Stepper failures.

  • dotnet build ./Microsoft.Maui.BuildTasks.slnf -v:q — passed.
  • dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -f net10.0-ios -p:RuntimeIdentifier=iossimulator-arm64 -v:q — passed; installed and locally validated as above using normal simulator signing.
  • dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -f net10.0-android -p:EmbedAssembliesIntoApk=true -v:q — passed; installed on an isolated headless API 34 emulator.
  • dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -f net10.0-maccatalyst -p:RuntimeIdentifier=maccatalyst-arm64 -v:q — passed; host UI automation was not run.
  • DEVICE_UDID=emulator-5556 dotnet test src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj --no-restore --filter 'FullyQualifiedName~Issue32463|FullyQualifiedName~Issue10222Test|FullyQualifiedName~VerifyButton_CommandAndCommandParameter' — 15 passed, including existing issue/gallery fixtures, per-test resets, and the legacy-navigation control.
  • dotnet build src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj -v:q — passed.
  • dotnet build src/Controls/tests/TestCases.Mac.Tests/Controls.TestCases.Mac.Tests.csproj -v:q — passed.
  • dotnet build src/Controls/tests/TestCases.WinUI.Tests/Controls.TestCases.WinUI.Tests.csproj -v:q — passed. Windows native execution was not performed locally on this macOS machine.
  • dotnet msbuild eng/helix.proj -getItem:XUnitProject -nologo — passed; includes the utility test project.

Earlier controlled runner verification:

$env:AdbTarget = '-s emulator-5556'
$env:DEVICE_UDID = 'emulator-5556'
$DeviceUdid = 'emulator-5556'
& .github/skills/verify-tests-fail-without-fix/scripts/verify-tests-fail.ps1 -Platform android -TestType UITest -TestFilter 'FullyQualifiedName~Issue32463Runner' -FixFiles 'src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs' -BaseBranch 079694193074be3809761c93f17338190279e292 -PRNumber 39621 -RequireFullVerification

VERIFICATION PASSED: legacy fixture setup failed the intended window-count assertion (expected 0, actual 1); restored direct-launch setup passed both selected tests. The original Android host verification also failed its three direct-launch cases without the host fix and passed all six with it. These earlier checks are not substitutes for the current native CI matrix.

Measured performance (limited local sample)

Three interleaved legacy/direct runs of the same two existing Android fixtures (Issue10222Test and VerifyButton_CommandAndCommandParameter), each with 2/2 tests passing. Compared full dotnet test --no-build wall time, including fixture setup, with MAUI_UITEST_DIRECT_LAUNCH=false versus true:

Mode Run 1 Run 2 Run 3 Median
Legacy navigation 20.938s 20.514s 20.819s 20.819s
Direct startup 16.237s 23.551s 15.575s 16.237s

The median was 22.0% lower in this sample; one direct run was slower. This is not a suite-wide estimate or a claim of an iOS/Windows speedup.

CI observation and remaining gaps

This PR is not runtime-green. The following terminal builds tested the preceding head f09f1302a01 through merge e00a7f22 on base 4781afbd; they do not validate the new termination correction.

  • Main validation 1649162 failed in Windows Debug: MSB4024 while reading generated .buildtasks/Microsoft.Maui.Core.props, which another process held open. The exact-base main build passed, but that is not causal proof. This failure is not the old WMC0612 XAML error from the initial implementation.
  • UI validation 1649164 failed. Its 85 failed result occurrences represent 73 distinct automated test/platform names, not 85 independent defects. Thirty CoreCLR Android ShellSearch outcomes share one fixture-setup timeout at _GalleryUITest.FixtureSetup:58. Five iOS Stepper assertions persist. Other assertion, timeout, app-not-running, and visual failures remain unresolved; neither passing utility tests nor isolated passing native cases clear them.
  • Windows ShellSearch has same-base peer-failure observations, while other Windows visuals have passing same-base cross-PR controls. Those are observations, not proof of PR causality or clearance. Some Catalyst Entry visual signatures also occur on main; remaining failures must not be dismissed as unrelated.
  • Device validation 1649165 succeeded, using a different harness. It does not certify Appium fixture lifecycle correctness.

A same-lane direct-launch-disabled control for the CoreCLR ShellSearch failure has not yet been performed. Its source-bound artifact confirms the requested startup target was sent, but diagnostics do not establish why setup timed out. No assertions, screenshot goldens, tolerances, or skips were changed to mask these failures.

Copilot AI balanced review requested due to automatic review settings October 24, 2026 18:53
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool October 24, 2026 18:53 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

🚀 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/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39621

Or

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

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool October 24, 2026 18:54 — with GitHub Actions Inactive
@azure-pipelines

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

No blocking defects were identified, but current required CI results remain unverified and need human confirmation beyond the reported local Android validation.

No open issues 🎉

What changed in this PR

Adds direct Android UI-test HostApp launch for #32463, extending the existing MacCatalyst startup-page resolver so automation can bypass gallery navigation.

Changes:

  • Reads the Android test intent extra during window creation, preserving gallery fallback for missing, empty, or unknown targets.
  • Adds six Android-only cases covering direct issue/gallery launch, case-insensitive matching, and fallback behavior.
  • Documents the launch command and requirement to stop the existing app first.
File Description
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue32463.cs Tests direct startup and gallery fallback without setup navigation.
src/​Controls/​tests/​TestCases.HostApp/​MauiProgram.cs Reads the Android startup target and logs unknown targets.
src/​Controls/​tests/​TestCases.HostApp/​Issues/​Issue32463.cs Adds a minimal page to verify direct launch.
docs/​UITesting-Guide.md Documents Android direct-launch usage and limitations.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 24, 2026 19:58
@kubaflo kubaflo changed the title [Testing] Allow Android UI-test host to launch directly to a test [Testing] Launch UI fixtures directly instead of navigating through the gallery Oct 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Apple relaunches can proceed after failed fallback termination, potentially retaining the previous fixture’s startup target.

1 open issue

Review effort: Balanced

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo
kubaflo force-pushed the kubaflo-issue-32463-fix branch from 1070673 to 790a87c Compare October 25, 2026 22:35
Copilot AI balanced review requested due to automatic review settings October 25, 2026 22:35
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Existing Android fixture behavior and reused-session recovery have unresolved regressions.

3 open issues

Review effort: Balanced

Comment on lines +52 to +53
if (existingContext is not null && ReferenceEquals(existingContext, _uiTestContext))
LaunchAppWithTest();
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Shared startup and session-lifecycle changes need human review because full native driver execution remains unverified on iOS, MacCatalyst, and Windows.

2 open issues
1 resolved since last review

Review effort: Balanced

@kubaflo

kubaflo commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/rebase

Require termination fallback commands to start, finish before timeout, and exit successfully. Surface reset close failures before relaunch and drain redirected output. Regressions exercise a real invalid simulator ID so a failed simctl command cannot be reported as a successful close.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: cdc98af7-0509-443d-8a84-cc75ecbc1a1e
Copilot AI balanced review requested due to automatic review settings October 26, 2026 17:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The fixture reset override ignores failed termination and can retain the previous app state instead of performing a clean reset.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Reset relaunches after failed app termination

src/​Controls/​tests/​TestCases.Shared.Tests/​UITest.cs:165

App.CloseApp() discards the close result, so this reset continues to launch even when both Appium termination and the OS fallback fail. On Windows or with direct launch disabled on iOS, that launch has no second termination check and can leave the previous page and state running. Use App.ResetApp(), which checks termination before relaunching and preserves the configured startup target.

1 resolved since last review

Review effort: Balanced

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@PureWeen PureWeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Adversarial review

Independent reviewer assessment of exact head 10e3dc7d710ecf1e93f8c5b163e3462aa0c90c25: no new actionable findings survived verification and adversarial consensus. This is not a clearance of issues already reported in prior feedback.

Reviewed the complete authoritative 22-file diff and relevant startup, fixture setup/reset/teardown, driver-session reuse, platform launch arguments, fallback termination, and test-project consumers. Methodology: 3 independent reviewers with adversarial consensus. Prior review bodies and comment/reply topology were checked for duplicate suppression; thread-resolution status was not verified.

The added utility tests exercise argument quoting, startup-target changes/session reuse, and lifecycle command/failure paths. Independently ran dotnet test src\TestUtils\tests\UITest.Appium.Tests\UITest.Appium.Tests.csproj -v:minimal: 22 passed, 0 failed, 0 skipped, targeting net10.0 with the available .NET 11 SDK. These recording-driver/unit tests do not establish native app readiness, cross-platform window timing, or recovery reliability. No native UI automation was performed.

Scope: code review only. CI/check status and merge readiness were not evaluated; use the repository's CI-analysis workflow for that assessment.

@kubaflo

kubaflo commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

@dalexsoto stamp

@kubaflo

kubaflo commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

UI-test timing comparison

Compared successful matching test-execution steps in PR build 1649164 with the median duration of each corresponding step across five completed main builds: 1648572, 1647951, 1646050, 1643718, and 1642149. Each included lane had at least three successful baseline samples; failed PR lanes were excluded.

Platform Matched lanes Main baseline (agent-minutes) PR (agent-minutes) Difference
Android 45 988.2 658.9 329.3 fewer
iOS 34 576.9 448.7 128.2 fewer
MacCatalyst 28 1,396.9 1,635.9 239.0 more
Windows 27 447.0 421.9 25.1 fewer

These are summed execution-step agent-minutes, not elapsed pipeline time or total pipeline resource usage. Lanes run in parallel. The baseline column sums per-lane medians, rather than representing one actual baseline run. The figures are rounded independently.

This is an observational comparison of the earlier PR head, not a benchmark of the latest head (10e3dc7d710). Machines, test counts, and coverage were not held constant, and excluding failed lanes creates selection bias. Therefore, these numbers do not establish that the PR caused the differences, a whole-suite speedup, or unchanged test coverage.

The smaller controlled Android comparison already documented in the PR is stronger evidence for the optimization itself: the same two passing tests took a median 20.819 seconds with legacy navigation versus 16.237 seconds with direct launch (22% lower across three runs per mode). That result is not a suite-wide or cross-platform estimate.

The Android/iOS CI timing is encouraging, but MacCatalyst was slower in this sample. These timing observations do not clear the outstanding UI failures or constitute a merge-readiness endorsement.

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Stamping as requested by @kubaflo; no code review performed.

@kubaflo
kubaflo merged commit 66921d2 into main Oct 27, 2026
180 of 206 checks passed
@kubaflo
kubaflo deleted the kubaflo-issue-32463-fix branch October 27, 2026 09:43
@github-actions github-actions Bot added this to the .NET 10 SR13 milestone Oct 27, 2026
NafeelaNazhir added a commit to NafeelaNazhir/maui that referenced this pull request Oct 28, 2026
…gating through the gallery"

Revert the net11 forward-port of PR dotnet#39621.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 28, 2026
… through the gallery (#39723)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!


### Description of Change

Revert #39621 because the direct UI fixture launch changes introduced
increased UI test failures on Android and iOS.

This restores the previous UI testing behavior, including gallery-based
fixture navigation, existing Appium lifecycle handling, and the prior
test infrastructure. The associated direct-launch implementation,
documentation, tests, and project references are removed.

### Issues Fixed

Reverts #39621.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 28, 2026
…igating through the gallery (#39724)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!


### Description of Change

Revert #39621 because the direct UI fixture launch changes introduced
increased UI test failures on Android and iOS.

This restores the previous UI testing behavior, including gallery-based
fixture navigation, existing Appium lifecycle handling, and the prior
test infrastructure. The associated direct-launch implementation,
documentation, tests, and project references are removed.

### Issues Fixed

Reverts #39621.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
sheiksyedm pushed a commit that referenced this pull request Oct 28, 2026
…stead of navigating through the gallery (#39730)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!


### Description of Change

Revert #39621 because the direct UI fixture launch changes introduced
increased UI test failures on Android and iOS.

This restores the previous UI testing behavior, including gallery-based
fixture navigation, existing Appium lifecycle handling, and the prior
test infrastructure. The associated direct-launch implementation,
documentation, tests, and project references are removed.

### Issues Fixed

Reverts #39621.

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.

[AGR] Fix android so it can launch directly to test

4 participants