[Testing] Rework Catalyst Test Runner to use startup arguments instead of UI navigation
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
PageFactoryproperty in theIssueModelclass to enable dynamic test page instantiation (TestCases.cs). -
Direct Test Page Retrieval: Implemented
TryToGetTestPage()inTestCaseScreento retrieve test pages by description usingPageFactory(TestCases.cs).
Platform-Specific Test Lifecycle Improvements:
-
Mac Catalyst Test Configuration: Enhanced
_IssuesUITestto 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
AppiumCatalystAppto 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
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/rebase
/azp run MAUI-UITests-public
Azure Pipelines successfully started running 1 pipeline(s).
/rebase
/azp run MAUI-UITests-public
Azure Pipelines successfully started running 1 pipeline(s).
/rebase
/azp run MAUI-UITests-public
Azure Pipelines successfully started running 1 pipeline(s).
🚀 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"
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/rebase
/rebase