Skip to content

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

Closed
ghost wants to merge 26 commits intomainfrom
unknown repository
Closed

[Testing] Rework Catalyst Test Runner to use startup arguments instead of UI navigation#30651
ghost wants to merge 26 commits intomainfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Jul 16, 2025

Description of Change

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

Screen.Recording.2025-07-15.at.7.08.33.PM.mov

Issues Fixed

Fixes #30285

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Jul 16, 2025
@ghost ghost added the area-testing Unit tests, device tests label Jul 16, 2025
@rmarinho
Copy link
Member

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

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

Test are failing on Mac:
image

One of the most repeated errors is the following one:

Exception details: System.TimeoutException: Timed out waiting for Go To Test button to appear
   at UITest.Appium.HelperExtensions.Wait(Func`1 query, Func`2 satisfactory, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2475
   at UITest.Appium.HelperExtensions.WaitForAtLeastOne(Func`1 query, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2490
   at UITest.Appium.HelperExtensions.WaitForElement(IApp app, String marked, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 679
   at Microsoft.Maui.TestCases.Tests.UtilExtensions.NavigateToGallery(IApp app, String page) in /_/src/Controls/tests/TestCases.Shared.Tests/UtilExtensions.cs:line 34
   at Microsoft.Maui.TestCases.Tests.CheckBoxUITests.NavigateToGallery() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/CheckBoxUITests.cs:line 17
   at Microsoft.Maui.TestCases.Tests.CoreGalleryBasePageTest.FixtureSetup() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/CoreGalleryBasePageTest.cs:line 19

Could you try to run locally a group of tests, like for example all the test from CheckBoxUITests.cs? What's the result?

@ghost
Copy link
Author

ghost commented Jul 17, 2025

Tests are failing on Mac:

@jsuarezruiz @rmarinho , Resolved the issues and committed changes, also ensured with multiple controls combination. Can you please re-trigger the CI once.

image

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@ghost ghost marked this pull request as ready for review July 23, 2025 07:53
Copilot AI review requested due to automatic review settings July 23, 2025 07:53
@ghost ghost self-requested a review as a code owner July 23, 2025 07:53
@ghost ghost requested review from jfversluis and mattleibow July 23, 2025 07:53

This comment was marked as outdated.

@ghost ghost requested a review from Copilot July 23, 2025 08:03
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 pull request reworks the Mac Catalyst test runner to streamline test execution by launching test pages directly via startup arguments instead of UI navigation. The changes enable programmatic test execution, reducing test setup time and improving reliability by bypassing the manual navigation flow required for other platforms.

Key changes include:

  • Added environment variable support for passing test names at startup to directly load test pages
  • Introduced PageFactory mechanism for dynamic page creation in test cases
  • Enhanced Mac Catalyst-specific test lifecycle management with direct app launch/close operations

Reviewed Changes

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

Show a summary per file
File Description
MauiProgram.cs Added logic to check environment variables for test names and directly create test pages for Mac Catalyst
TestCases.cs Added PageFactory property and TryToGetTestPage() method for dynamic page retrieval
CorePageView.cs Added TryToGetGalleryPage() method for gallery page retrieval by title
_IssuesUITest.cs Enhanced with Mac Catalyst startup argument configuration and direct test launching
UITestContextBase.cs Added abstract methods for app lifecycle management and Mac-specific initialization
UITestBase.cs Modified teardown to handle Mac-specific app closure
AppiumCatalystApp.cs Updated to include environment variables in Appium options
AppiumLifecycleActions.cs Modified to use launchApp instead of activateApp for Mac with environment variables
HelperExtensions.cs Added parameterized app launch method supporting test-specific configurations
UtilExtensions.cs Updated navigation logic to skip UI navigation for Mac Catalyst
Multiple test files Added GalleryPageName property overrides and converted to _GalleryUITest base class
Comments suppressed due to low confidence (3)

src/Controls/tests/TestCases.Shared.Tests/Tests/SwipeViewUITests.cs:11

  • The constant name SwipeViewGallery should follow the existing naming pattern. The previous constant was named ScrollViewGallery but should have been SwipeViewGallery to match the content.
		const string SwipeViewGallery = "SwipeView Gallery";

@ghost ghost requested a review from jsuarezruiz July 23, 2025 09:54
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@ghost ghost added the testing-infrastructure Issue relating to testing infrastructure label Aug 3, 2025
@ghost ghost closed this by deleting the head repository Sep 17, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2025
This pull request was closed.
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 partner/syncfusion Issues / PR's with Syncfusion collaboration testing-infrastructure Issue relating to testing infrastructure

Projects

None yet

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

4 participants