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

No test found in a WinUI 3 Unit Test App #438

Open
JulienTheron opened this issue Jan 13, 2025 · 2 comments
Open

No test found in a WinUI 3 Unit Test App #438

JulienTheron opened this issue Jan 13, 2025 · 2 comments

Comments

@JulienTheron
Copy link

This is a follow-up to #423, as the issue is still reproducible with xunit.runner.visualstudio v3.

In short, one cannot use xUnit to run .NET tests that require package identity, like you could do with UWP.

Using the Unit Test App (WinUI 3 in Desktop) project template, and replacing the MSTest NuGet packages with the xUnit equivalents, the projects builds without errors, and tests appear in Visual Studio's Test Explorer, but they do not run. They're not discovered at runtime: Test discovery finished: 0 Tests found in 1,2 sec

A repro project is included: UnitTestApp.zip

Thanks.

@bradwilson
Copy link
Member

bradwilson commented Jan 13, 2025

We don't explicitly support WinUI 3.

That said, I can't get your project to run dotnet test correctly because of build issues:

$ dotnet test
Restore complete (0.2s)
  UnitTestApp failed with 1 error(s) and 1 warning(s) (6.0s) → bin\Debug\net8.0-windows10.0.19041.0\UnitTestApp.dll
    C:\Program Files\dotnet\sdk\9.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(208,5): warning NETSDK1198: A publish profile with the name 'win-AnyCPU.pubxml' was not found in the project. Set the PublishProfile property to a valid file name.
    C:\Users\bradwilson\.nuget\packages\microsoft.windowsappsdk\1.6.241114003\buildTransitive\Microsoft.Build.Msix.Packaging.targets(1055,5): error : Packaged .NET applications with an app host exe cannot be ProcessorArchitecture neutral. Please specify a RuntimeIdentifier or a Platform other than AnyCPU.

Build failed with 1 error(s) and 1 warning(s) in 6.6s

@JulienTheron
Copy link
Author

We don't explicitly support WinUI 3.

Should I enter a feature request then?

That said, I can't get your project to run dotnet test correctly because of build issues:

WinUI 3 projects are architecture-specific. You have to specify the platform: dotnet test UnitTestApp.csproj /p:Platform=x64
In that case, tests do run, but they run as unpackaged, so the test fails because the Package.Current API can't be called without package identity.
When using the Visual Studio Test Explorer, however, tests do not run.

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

2 participants