Skip to content

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 the community ✨ Community Contribution label Sep 18, 2025
Copy link
Contributor

Hey there @@NafeelaNazhir! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label 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 Copilot AI review requested due to automatic review settings September 18, 2025 10:37
Copy link
Contributor

@Copilot 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

@@ -20,7 +20,7 @@ public Bugzilla40092(TestDevice testDevice) : base(testDevice)
[Category(UITestCategories.BoxView)]
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
Preview

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
Preview

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 const string ScrollViewFeatureMatrix = "ScrollView Feature Matrix";
override public string GalleryPageName => ScrollViewFeatureMatrix;
Copy link
Preview

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
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
2 participants