-
Notifications
You must be signed in to change notification settings - Fork 79
Closed
Labels
Milestone
Description
Problem
We want our unit tests to not just be able to test .NET code, but also be able to exercise the UI to the extent possible in the UWP/WinUI test app scenarios.
Existing Solution
In the toolkit, we have a helper class called VisualUITestBase which allows a developer writing a unit test with UITestMethod to set the content of the test app temporarily in order to exercise a component, check its layout, and test other parts which may be required for the control to be visualized.
New Solutions
- Currently a lot of these tests use
XamlReaderto load XAML from code-behind to create their scenarios. This is a bit cumbersome, especially without the upcoming raw C# string literals. I'd like to investigate using an attribute style solution like we did for the Toolkit UI tests, so loose XAML files can be used to load test scenarios directly within the application. - Once we reach this point, we get pretty close to being able to do more complex UI testing, it'd be great if we could try and bridge the complexity gap of the UI Testing systems that are really hard to work with on automation APIs and connecting test runners and the test hosting apps (and being able to run those in the CI across multiple automation framework technologies)... to instead just build on what we know works easily in the unit test structure that exists with MSTest and see if we can provide some basic UI manipulation helpers in order to test more complex scenarios.
Proposal Breakdown
- Independent: Rename
CommunityToolkit.Labs.Sharedproject toCommunityToolkit.Labs.SampleApp.Shared - Create a new
common\Communitytoolkit.Labs.UnitTests.Sharedshared project (to appear under theSharedSolution folder)- Add this to the root test heads
- Remove all
App.xaml/UnitTestApp.xamlandMainWindow.xamlfiles from unit test heads - Centralize on
CommunityToolkit.Labs.UnitTestsnamespace - Use a common
App.xamlfile to include WinUI 2 and WinUI 3 for all the test heads (just like the individual platform heads do) - Abstract the startup for UWP vs. WinUI 3 (see project heads shared
App.xaml.csfile) - Make sure
WINAPPSDKconditional works the same for unit test projects
- Add
VisualUITestBaseclass from Toolkit version- Add the new shared unit test project to the experiment shared projects
- Add 7.1.2 Toolkit references for UWP/WinUI 3 for Visual Tree helpers and the like
- New
VisualUITestBaseimprovements - handled by API Spec for Reunion Deployment Information API microsoft/WindowsAppSDK#156 now- Add ability to lookup attribute in
TestInitializein base class - Load from page in shared experiment project
- Auto Dispatch? (all these UI tests had to dispatch to the UI thread to load, so we can automatically handle that I think?).
- Add ability to lookup attribute in
- Test works in all environments:
- UWP/WinUI 3 with all solution
- UWP/WinUI with experiment solution
- CI
-
Investigate helper methods for more 'ui testing' scenarios-
Since we own the apps and their deployment can we use more restricted capabilities like the InputInjection rescap? And does that work in WinUI 3 as well? -
Does this work in the CI?
-
-
UseGridSplitteras a test case and see if we can:- [ ]~ Test Localization (will be good test for UWP/WinUI 3 and resource loading)~
-
Test a mouse drag (if we get injector working) replicate the UI Test we had for GridSplitter