Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add App UI testing project #62

Open
deansheather opened this issue Mar 24, 2025 · 1 comment
Open

Add App UI testing project #62

deansheather opened this issue Mar 24, 2025 · 1 comment

Comments

@deansheather
Copy link
Member

We need a separate project for testing UI-related code from the App project. We currently have Tests.App but we probably should add Tests.App.UI as a separate project.

Test code needs to be launched on a UI thread inside of a window's DispatchQueue.

I've tried doing the following in a new solution to see how feasible it is to do, but have run into issue after issue:

  1. create App project from winui3 template
  2. create AppTest project from winui3 unit testing template
  3. add DependencyObjectSelector.cs to App (which doesn't depend on anything so it's just a simple copy/paste and change namespace)
  4. add DependencyObjectSelectorTest.cs to AppTest, and accept the suggestion to add a project reference to App
  5. click the greyed out test run icon beside the test method, accept the prompt to install Microsoft.NET.Test.Sdk
    click the green test run icon
  6. Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point.
  7. add <StartupObject>AppTest.Program</StartupObject> (which is the XAML generated main from winui 3)
  8. An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute 'Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer.UITestMethodAttribute'.

I've also tried using the entry point from Microsoft.NET.Test.Sdk (which is empty) and doing winui 3 startup in an AssemblyInitializer, and it gets a bit further but I run into XAML loading issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant