-
Notifications
You must be signed in to change notification settings - Fork 106
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
Unit tests on a C#/WinRT projection does not start #1047
Comments
@nseveno - I took a look at the repro, and the issue is that the test project is not using a packaged app. Currently unpackaged C#/WinRT apps are not working with MSTest. Here is an example of a packaged app using MSTest (note the package manifest, and the use of |
There's no reason MSTest cannot execute unpackaged C#/WinRT projection code. This is a regression in MSTest, which was introduced with the WinUI support. That support is triggered via a specific test method attribute, UITestMethod. But independently, the test project's TFM also determines the test adapter to copy from the nuget. E.g., a value of net5.0-windows10.0.19041 copies the PlatformServices.WinUI adapter from "%NUGET_PACKAGES%\mstest.testadapter\2.2.5\build\net5.0-windows10.0.18362.0\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll". The problem is that the WinUI test adapter assumes packaged execution in calls [like this]:(https://github.com/microsoft/testfx/blob/19acefa11712c387774784a79dafcf7b3dbee64c/src/Adapter/PlatformServices.WinUI/Services/WinUIFileOperations.cs#L109):
The test code here is not using WinUI, so it could just rely on the PlatformService.Desktop adapter code, but the TFM behavior above doesn't support that. You can back off to an earlier version of MSTest (I verified that 2.23 works) and you could also enter a bug in the MSTest repo to support unpackaged: |
Thanks for answering. Downgrading to 2.2.3 works ! For reference, I just had to change the nuget references, rebuild and reopen the solution. I think this existing bug in the MSTest repo should fix the problem. Since the problem will be solved by the MSTest team, I close this bug. |
This problem is solved in MSTest nugets version 2.2.10. |
Describe the bug
I have a solution with some C++/WinRT components that perform audio processing.
I created a C#/WinRT projection for theses components.
My graphical interface (C# / WinUI 3) uses this projection. It works great.
I would like to be able to unit test my C++/WinRT components in a C# MS Test project. (As my GUI is in C#, I would like to be able to write theses tests in C#).
So I created a C# MS Test project. I referenced the projection project.
When I launch a unit test, it never starts. Instead, a "file not found" error appears in the "Tests" output.
I already filed a bug on the developercommunity.visualstudio.com website.
But without success. Maybe it was in the wrong team ?
I'm stuck in my project, with a lot of C++ code, and I'm not able to test it. Very frustrating...
Mabe someone here could give me a workaround ?
To Reproduce
I created a minimal repro project.
ReproUnitTestProjection.zip
Just open the solution in the Zip.
Select Debug|x64 for the current configuration / platform
Rebuild the solution
Open the tests explorer
In the “ViewModelTests” class, try to run the “SayHelloTest” unit test => Nothing happens
In the output window, select the “Tests” output => You should see the following error message :
Expected behavior
The unit tests should run.
Version Info
Visual Studio 2022 current version
C++/WinRT last version
Microsoft.Windows.CsWinRT version 1.3.5
(WinUI 3 version 1.0.0-preview3)
Additional context
The text was updated successfully, but these errors were encountered: