microsoft / testfx

MSTest framework and adapter
MIT License
714 stars 253 forks source link

Cannot discover tests in a UWP ARM64 app #1627

Closed mstefarov closed 1 year ago

mstefarov commented 1 year ago

Describe the bug

When I try to run UWP tests from an app built for ARM64, no tests are discovered.

I have Arm64 Visual Studio 17.5.3 Pro installed, running under Windows 11 Pro (10.0.22000), on an ARM64 machine (Windows Dev Kit 2023). My test app is built for ARM64, packaged in MSIX, with certificate already installed.

I execute tests from VS Developer Command Prompt, using this command:

VSTest.Console
  Path\To\Package\My.Tests.Universal_1.0.0.0_arm64_DEBUG.msix
  /InIsolation
  --Blame:CollectDump;CollectAlways=false;DumpType=full
  /Diag:Path\To\Output\UWP_arm64.log
  /framework:FrameworkUap10
  /logger:trx;LogFileName=Path\To\Output\UWP_arm64.TRX
  /Platform:arm64
  /ResultsDirectory:Path\To\Output\
  /Settings:testsettings.runsettings

I see VSTest deploys the app successfully but does not execute any tests. I attached the diagnostic logs. The following is logged to console:

No test is available in My.Tests.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again. Closing app with package full name 'CC7B783B-E38E-42F8-95FF-62916F1FA93D_1.0.0.0_arm64__zy2ctb9gr90we'. Results File: Path\To\Output\UWP_arm64.TRX Additionally, path to test adapters can be specified using /TestAdapterPath command. Example /TestAdapterPath:<pathToCustomAdapters>.

When I build the app for other architectures (e.g. x64), tests are discovered and executed normally on this ARM64 machine. The problem only happens when my package targets ARM64.

Steps To Reproduce

Expected behavior

Actual behavior

Additional context

I already tried clearing my temp folder as suggested here, but it did not make a difference.

I also tried upgrading Microsoft.NET.Test.Sdk used by my UWP test project from 16.11.0 (the default version set by Microsoft.Windows.UI.Xaml.Common.Targets) to latest-stable (17.5.0) by setting UwpUnitTestSdkPkgVersion property, but it also did not help.

Logs from vstest.console: UNITTEST_UWP_3836_arm64.TRX.datacollector.23-04-05_15-33-39_29857_1.log UNITTEST_UWP_3836_arm64.TRX.diagnostic.log

My runsettings file ```xml True ARM64 30000 ```
mstefarov commented 1 year ago

I wonder if the problem is that UWP on ARM64 always uses the native tool chain. I gathered that there are some known test discovery issues with the native tool chain.

I made sure to build the test app in Debug configuration, and I added <Assembly Name="*Application*" Dynamic="Required All" DoNotOptimize="true" DoNotInline="true" /> in my unit test's runtime directives, but it does not appear to help. I verified that my test methods did not get optimized away:

2023-04-06_171632 devenv

Since UWP for ARM64 always uses native tool chain, is running unit tests on UWP ARM64 supported at all?

Evangelink commented 1 year ago

Hi @mstefarov,

I am sorry but I have no idea if this is working or supported at all. I took over mstest but we have no test for UWP and I am not familiar enough with it to add some at the moment. @MSLukeWest do you know if this is something that is working? Is there anything we need to do on mstest side?

MSLukeWest commented 1 year ago

@Evangelink This scenario is supported and working in the latest 17.5 builds. I just confirmed this by creating a new C# UWP unit test project on an arm64 Surface Pro X machine, switching the platform to arm64, and running the tests in the IDE. The test was correctly discovered and passed.

@mstefarov Correctly points out that arm64 UWP runs with the .NET native toolchain even when using the debug config, but this shouldn't prevent the tests from being discovered. I left this setting on during my verification.

dotMorten commented 1 year ago

@mslukewest did you double-check in process explorer that it actually runs ARM64? I noticed the VS test settings can be quite finicky and often wants to run as x64 anyway.

MSLukeWest commented 1 year ago

@dotMorten I double checked and yes, both processes were running arm64:

microsoft-github-policy-service[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 10 days of this comment.