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

[Bug] There are no example NUnit or MSTest projects for testing Maui libraries using VS 2022 preview 4 #2594

Closed
Zachael opened this issue Sep 20, 2021 · 1 comment
Labels
area-templates Project templates, Item Templates for Blazor and MAUI t/bug Something isn't working

Comments

@Zachael
Copy link

Zachael commented Sep 20, 2021

Prior to the introduction of workloads, it was possible to write NUnit projects for a Maui library. The project created virtual controls within a Windows executable without creating the native controls.

With VS 2022 preview 4, the project gives the error:
The framework 'Microsoft.Maui.Core', version 'FromWorkload' (x64) was not found.

It was also possible to write MSTest unit tests that launched the unit tests as a MSIX application using the the following code in App.xaml.cs (using MSTest.TestFramework, MSTest.TestAdapter, Microsoft.TestPlatform.TestHost and coverlet.collector).

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
     base.OnLaunched(args);

     Microsoft.Maui.Essentials.Platform.OnLaunched(args);

     Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();

     UITestMethodAttribute.DispatcherQueue = MainWindow.DispatcherQueue;

     Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(Environment.CommandLine);
}

With VS2022 preview 4, the MSTest project gives the error:
error CS7069: Reference to type 'DispatcherQueue' claims it is defined in 'Microsoft.WinUI', but it could not be found

What is the guidance for writing unit tests which can be run within VS for testing Maui libraries for Windows?

@Eilon Eilon added the area-templates Project templates, Item Templates for Blazor and MAUI label Sep 28, 2021
@jsuarezruiz jsuarezruiz added the t/bug Something isn't working label Oct 22, 2021
@Eilon
Copy link
Member

Eilon commented Feb 11, 2022

Dup of #2112

@Eilon Eilon closed this as completed Feb 11, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Mar 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-templates Project templates, Item Templates for Blazor and MAUI t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants