Replies: 6 comments 5 replies
-
One option is to break your logic you want to test out into another class library that targets just net6.0 and then you add that as a reference to your .NET MAUI app and your Unit Test project |
Beta Was this translation helpful? Give feedback.
-
@jamesmontemagno I needed to create a new Maui library project and manually added an additional net6.0 target by editing the project. A normal .net core class library doesn't work because I can't reference it in the maui project anymore. |
Beta Was this translation helpful? Give feedback.
-
I added |
Beta Was this translation helpful? Give feedback.
-
I'm also having a similar problem with unit testing a Maui project with XUnit. I've created the test project, added net6.0 as a target framework to my main project, added
Creating a Right now I can test by leaving the entry |
Beta Was this translation helpful? Give feedback.
-
I've got this working with the same trick that Fabbrik1976 showed. However, when I run
it shows 0 lines / branches in coverage.cobertura.xml. Anyone else having this problem? |
Beta Was this translation helpful? Give feedback.
-
Did anyone is able to fix these code coverage issue ? I am also facing same issue |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm just getting started with maui and try to test my business logic. When adding a test project into my VS solution I can't reference the maui project for testing. I've also tried moving my business logic to a separate class library and test it there which also doesn't work. I'm always getting errors about unsupported target frameworks "net6.0-windows10.0.19041".
I don't care which framework to use at the moment. Just trying to get some tests running. I'm using latest VS2022 preview and started from the default code for a new project adding just a single class to it.
What is the way to go for unit testing with maui?
Beta Was this translation helpful? Give feedback.
All reactions