Skip to content

[Testing] Rework Catalyst Test Runner to use startup arguments instead of UI navigation #31673

Merged
PureWeen merged 10 commits intodotnet:mainfrom
NafeelaNazhir:enhance_mac_uiTest
Dec 22, 2025
Merged

[Testing] Rework Catalyst Test Runner to use startup arguments instead of UI navigation #31673
PureWeen merged 10 commits intodotnet:mainfrom
NafeelaNazhir:enhance_mac_uiTest

Conversation

@NafeelaNazhir
Copy link
Contributor

Description of Change

This PR reopens the work from the closed #30651

This pull request introduces functionality to streamline test execution by allowing tests to be launched directly via startup arguments or programmatically. Key changes include adding support for passing test names as environment variables, introducing a PageFactory mechanism for dynamic page creation, and enhancing test lifecycle management for specific platforms like Mac Catalyst.

Note: This PR is an extension of the PR(#30286) with a proper implementation.

Test Execution Enhancements:

  • Startup Argument Support: Added logic to retrieve test names from environment variables and dynamically load the corresponding test page in CreateDefaultMainPage() (MauiProgram.cs).

  • Dynamic Page Creation: Introduced a PageFactory property in the IssueModel class to enable dynamic test page instantiation (TestCases.cs).

  • Direct Test Page Retrieval: Implemented TryToGetTestPage() in TestCaseScreen to retrieve test pages by description using PageFactory (TestCases.cs).

Platform-Specific Test Lifecycle Improvements:

  • Mac Catalyst Test Configuration: Enhanced _IssuesUITest to pass test names as startup arguments and manage app launch/close lifecycle specifically for Mac Catalyst (_IssuesUITest.cs). [1] [2]

  • ** Appium Options for Mac Catalyst**: Updated AppiumCatalystApp to include environment variables in Appium options for test execution (AppiumCatalystApp.cs).

Helper Methods for Test Execution:

  • Parameterized App Launch: Added a method to launch apps with additional parameters, supporting test-specific configurations (HelperExtensions.cs).

  • Mac-Specific App Closure: Modified FixtureOneTimeTearDown() to handle app closure for Mac Catalyst during test teardown (UITestBase.cs).

Output

467025436-e594828d-93bb-4e41-b583-7d5b4ab2a0b9.mov

Issues Fixed

Fixes #30285

@NafeelaNazhir NafeelaNazhir added the area-testing Unit tests, device tests label Sep 18, 2025
@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Sep 18, 2025
@NafeelaNazhir NafeelaNazhir added testing-infrastructure Issue relating to testing infrastructure community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration and removed community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Sep 18, 2025
@NafeelaNazhir NafeelaNazhir marked this pull request as ready for review September 18, 2025 10:36
Copilot AI review requested due to automatic review settings September 18, 2025 10:37
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 reworks the Mac Catalyst test runner to enable direct test execution via startup arguments instead of requiring UI navigation. The change streamlines test execution by allowing tests to launch directly through environment variables and programmatic page creation.

Key Changes:

  • Enhanced test lifecycle management for Mac Catalyst with direct page loading via startup arguments
  • Introduced a new _GalleryUITest base class to simplify gallery-based test implementations
  • Added PageFactory mechanism for dynamic test page instantiation

Reviewed Changes

Copilot reviewed 76 out of 78 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/TestUtils/src/UITest.NUnit/UITestContextBase.cs Added Mac-specific app launch handling in InitialSetup
src/TestUtils/src/UITest.NUnit/UITestBase.cs Enhanced teardown logic with Mac-specific app closure
src/TestUtils/src/UITest.Appium/HelperExtensions.cs Added LaunchApp overload to support test name parameters
src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs Enhanced Appium options to include environment variables
src/TestUtils/src/UITest.Appium/Actions/AppiumLifecycleActions.cs Modified Mac app launch to use environment variables
src/Controls/tests/TestCases.Shared.Tests/UtilExtensions.cs Updated NavigateToGallery to skip navigation for Catalyst
src/Controls/tests/TestCases.Shared.Tests/UITest.cs Implemented Close and LaunchAppWithTest methods
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs Added Mac Catalyst startup argument support
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_GalleryUITest.cs New base class for gallery-based tests
src/Controls/tests/TestCases.HostApp/TestCases.cs Added PageFactory property and TryToGetTestPage method
src/Controls/tests/TestCases.HostApp/MauiProgram.cs Enhanced CreateDefaultMainPage with startup argument handling
Various test classes Updated to inherit from _GalleryUITest and added GalleryPageName properties

public void AllScreenIsBlack()
{
#if !ANDROID // Display alert not shown in android also this is not a needed one for ensuring this case, so ignored the below steps on Android.
#if !ANDROID && !MACCATALYST // Display alert is not shown on Android, and it is not required to validate this case, so the following steps are skipped for Android. For Catalyst, the test page loading flow has been modified, making the popup validation unnecessary here as well.
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

[nitpick] The comment should be split into separate lines for better readability and clarity. Consider formatting as a multi-line comment or breaking it into shorter, more focused comments.

Suggested change
#if !ANDROID && !MACCATALYST // Display alert is not shown on Android, and it is not required to validate this case, so the following steps are skipped for Android. For Catalyst, the test page loading flow has been modified, making the popup validation unnecessary here as well.
// Display alert is not shown on Android, and it is not required to validate this case,
// so the following steps are skipped for Android.
// For Catalyst, the test page loading flow has been modified,
// making the popup validation unnecessary here as well.
#if !ANDROID && !MACCATALYST

Copilot uses AI. Check for mistakes.
public SearchBarFeatureTests(TestDevice testDevice) : base(testDevice)
{
}
override public string GalleryPageName => SearchBarFeatureMatrix;
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The access modifier 'override' should come after 'public' according to C# coding conventions. It should be 'public override string GalleryPageName'.

Suggested change
override public string GalleryPageName => SearchBarFeatureMatrix;
public override string GalleryPageName => SearchBarFeatureMatrix;

Copilot uses AI. Check for mistakes.
public class ScrollViewFeatureTests : _GalleryUITest
{
public const string ScrollViewFeatureMatrix = "ScrollView Feature Matrix";
override public string GalleryPageName => ScrollViewFeatureMatrix;
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The access modifier 'override' should come after 'public' according to C# coding conventions. It should be 'public override string GalleryPageName'.

Suggested change
override public string GalleryPageName => ScrollViewFeatureMatrix;
public override string GalleryPageName => ScrollViewFeatureMatrix;

Copilot uses AI. Check for mistakes.
@jsuarezruiz
Copy link
Contributor

/azp run

@jsuarezruiz jsuarezruiz self-assigned this Sep 18, 2025
@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

/// then by description if no match is found by name. If a match is found,
/// it invokes the associated PageFactory to create the page.
/// </remarks>
public Page TryToGetTestPage(string name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can try the exact match first:

var exactMatch = TestCases.FirstOrDefault(x => 
            string.Equals(x.Description, description, StringComparison.OrdinalIgnoreCase));

if not find it, the current partial match as fallback.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz I have addressed the feedback in the latest commit.

@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Oct 10, 2025
@rmarinho rmarinho modified the milestones: .NET 10.0 GA, .NET 10 SR1 Oct 22, 2025
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

/rebase

@PureWeen PureWeen added the p/0 Current heighest priority issues that we are targeting for a release. label Oct 31, 2025
@PureWeen
Copy link
Member

PureWeen commented Dec 4, 2025

/rebase

@sheiksyedm
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

🚀 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 -- 31673

Or

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

@sheiksyedm
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@sheiksyedm
Copy link
Contributor

/rebase

@sheiksyedm
Copy link
Contributor

/rebase

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

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

Amazing!!!

Going to merge as is but I was curious on the tests where you have it switched to CarouselView2 and CollectionView2. Do we need to log those as bugs?

@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Dec 22, 2025
@PureWeen PureWeen merged commit a14b855 into dotnet:main Dec 22, 2025
159 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Dec 22, 2025
StephaneDelcroix pushed a commit that referenced this pull request Jan 5, 2026
…d of UI navigation (#31673)

### Description of Change

#### This PR reopens the work from the closed
[#30651](#30651)

This pull request introduces functionality to streamline test execution
by allowing tests to be launched directly via startup arguments or
programmatically. Key changes include adding support for passing test
names as environment variables, introducing a `PageFactory` mechanism
for dynamic page creation, and enhancing test lifecycle management for
specific platforms like Mac Catalyst.

Note: This PR is an extension of the
PR(#30286) with a proper
implementation.

#### Test Execution Enhancements:

- **Startup Argument Support**: Added logic to retrieve test names from
environment variables and dynamically load the corresponding test page
in `CreateDefaultMainPage()` (`MauiProgram.cs`).

- **Dynamic Page Creation**: Introduced a `PageFactory` property in the
`IssueModel` class to enable dynamic test page instantiation
(`TestCases.cs`).

- **Direct Test Page Retrieval**: Implemented `TryToGetTestPage()` in
`TestCaseScreen` to retrieve test pages by description using
`PageFactory` (`TestCases.cs`).

#### Platform-Specific Test Lifecycle Improvements:

- **Mac Catalyst Test Configuration**: Enhanced `_IssuesUITest` to pass
test names as startup arguments and manage app launch/close lifecycle
specifically for Mac Catalyst (`_IssuesUITest.cs`).
[[1]](https://github.com/dotnet/maui/pull/30651/files#diff-6e8c0ea1f2979b5484d14facb1aa5b2ccef3ee748f1606eaf46220ac0936e3edR22-R46)
[[2]](https://github.com/dotnet/maui/pull/30651/files#diff-6e8c0ea1f2979b5484d14facb1aa5b2ccef3ee748f1606eaf46220ac0936e3edR58-R61)

- ** Appium Options for Mac Catalyst**: Updated `AppiumCatalystApp` to
include environment variables in Appium options for test execution
(`AppiumCatalystApp.cs`).

#### Helper Methods for Test Execution:

- **Parameterized App Launch**: Added a method to launch apps with
additional parameters, supporting test-specific configurations
(`HelperExtensions.cs`).

- **Mac-Specific App Closure**: Modified `FixtureOneTimeTearDown()` to
handle app closure for Mac Catalyst during test teardown
(`UITestBase.cs`).

 ### Output


https://github.com/user-attachments/assets/82fc12ad-b0d3-4bad-901f-0ab6b2bddda1



### Issues Fixed

Fixes #30285
@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-testing Unit tests, device tests community ✨ Community Contribution p/0 Current heighest priority issues that we are targeting for a release. partner/syncfusion Issues / PR's with Syncfusion collaboration testing-infrastructure Issue relating to testing infrastructure

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Testing] Rework the Catalyst Test Runner so that it will pass in the next test as a startup argument vs navigating by keyboard

5 participants