maui icon indicating copy to clipboard operation
maui copied to clipboard

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

Open NafeelaNazhir opened this issue 3 months ago • 16 comments

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(https://github.com/dotnet/maui/pull/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

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

Issues Fixed

Fixes https://github.com/dotnet/maui/issues/30285

NafeelaNazhir avatar Sep 18 '25 10:09 NafeelaNazhir

/azp run

jsuarezruiz avatar Sep 18 '25 11:09 jsuarezruiz

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Sep 18 '25 11:09 azure-pipelines[bot]

/azp run

jsuarezruiz avatar Sep 26 '25 07:09 jsuarezruiz

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Sep 26 '25 07:09 azure-pipelines[bot]

/azp run

jsuarezruiz avatar Oct 27 '25 15:10 jsuarezruiz

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Oct 27 '25 15:10 azure-pipelines[bot]

/rebase

PureWeen avatar Oct 31 '25 23:10 PureWeen

/azp run MAUI-UITests-public

sheiksyedm avatar Nov 11 '25 10:11 sheiksyedm

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Nov 11 '25 10:11 azure-pipelines[bot]

/rebase

sheiksyedm avatar Nov 21 '25 07:11 sheiksyedm

/azp run MAUI-UITests-public

sheiksyedm avatar Nov 27 '25 13:11 sheiksyedm

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Nov 27 '25 13:11 azure-pipelines[bot]

/rebase

PureWeen avatar Dec 04 '25 00:12 PureWeen

/azp run MAUI-UITests-public

sheiksyedm avatar Dec 07 '25 13:12 sheiksyedm

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Dec 07 '25 13:12 azure-pipelines[bot]

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

github-actions[bot] avatar Dec 09 '25 06:12 github-actions[bot]

/azp run

sheiksyedm avatar Dec 11 '25 15:12 sheiksyedm

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Dec 11 '25 15:12 azure-pipelines[bot]

/rebase

sheiksyedm avatar Dec 15 '25 18:12 sheiksyedm

/rebase

sheiksyedm avatar Dec 18 '25 08:12 sheiksyedm