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 Code Coverage if the "CommunityToolkit.Maui" package is referenced #413

Closed
pauldavis-dwe opened this issue Apr 3, 2024 · 20 comments
Closed

Comments

@pauldavis-dwe
Copy link

pauldavis-dwe commented Apr 3, 2024

Installed product versions

  • Visual Studio: 2022 Professional
  • This extension: 1.1.214

Description

If a project includes the "CommunityToolkit.Maui" nuget package then no code coverage results are generated

Steps to recreate

  1. Make a class library, with a class containing a public method
  2. Make a test project with a test for that public method
  3. Run the test and see code coverage results
  4. Add the "CommunityToolkit.Maui" package to the class library
  5. Run the test and see NO code coverage results

Current behavior

No code coverage results are shown

Expected behavior

Code coverage results should be shown

Cobertura XML: Cobertura.xml.txt

@tonyhallett
Copy link
Collaborator

Please can you post the contents of the FCC Output Window Pane.

@tonyhallett
Copy link
Collaborator

Also are you using ms code coverage ?

@pauldavis-dwe
Copy link
Author

Coverage tab:
image

Coverage Log:
image

No, I'm not using MS Code Coverage

@tonyhallett
Copy link
Collaborator

Please can you post the contents of the FCC Output Window Pane.

image

@tonyhallett
Copy link
Collaborator

I think you'll find that this is not an issue with FCC but a limitation with MAUI

@pauldavis-dwe
Copy link
Author

FCC output: https://pastebin.com/0JQeeqiC
But if I remove the package, my test library works. So how is it MAUI?

@pauldavis-dwe
Copy link
Author

Created a repo to demonstrate: https://github.com/pauldavis-dwe/FccBugRepro.git

@tonyhallett
Copy link
Collaborator

Can you set RunMsCodeCoverage Yes and see if you get the same result

@pauldavis-dwe
Copy link
Author

pauldavis-dwe commented Apr 3, 2024

I thought for a moment that worked, but no. It DOES now show coverage for the UnitTests project but not for the Core project:
image

@tonyhallett
Copy link
Collaborator

Does the cobertura agree with what you now see ?

@pauldavis-dwe
Copy link
Author

The Cobertura.xml file now has lots more in it for the Dwellant.ResidentApp.Core.UnitTests "package" but nothing for Dwellant.ResidentApp.Core which is the assembly I am testing

@tonyhallett
Copy link
Collaborator

I have installed the Maui components and run coverage on your https://github.com/pauldavis-dwe/FccBugRepro.git
With the package reference and RunMsCodeCoverage Yes code coverage is collected.

image

Although with coverlet it is not. It looks like FCC will need to update the version of Coverlet that it uses to
https://github.com/coverlet-coverage/coverlet/releases/tag/v6.0.0

Can you show the FCC Output Window Pane output just for the MS Code Coverage Run.

@tonyhallett
Copy link
Collaborator

Until I update coverlet you can do the following.

  1. Download the package - https://www.nuget.org/api/v2/package/coverlet.collector/6.0.2
  2. Change the file extension to zip
  3. Extract the zip
  4. Provide this directory to FCC
image

--

But can you still show the FCC Output Window Pane output just for the MS Code Coverage Run.

@pauldavis-dwe
Copy link
Author

I have installed the Maui components and run coverage on your https://github.com/pauldavis-dwe/FccBugRepro.git With the package reference and RunMsCodeCoverage Yes code coverage is collected.

I just tried that and I still get no coverage. Do you perhaps have a dev version or have other non-default FCC settings?

@pauldavis-dwe
Copy link
Author

But can you still show the FCC Output Window Pane output just for the MS Code Coverage Run.

Sure: https://pastebin.com/Mq3UbiEF

@pauldavis-dwe
Copy link
Author

Have tried the coverlet suggestion but still no coverage

@tonyhallett
Copy link
Collaborator

Sorry forget to mention that you need to add UseDataCollector project property to your test projects.

@tonyhallett
Copy link
Collaborator

Can you show the TestProject1-fcc-mscodecoverage-generated.runsettings in the bin directory.

@pauldavis-dwe
Copy link
Author

Fantastic! Including UseDataCollector means I get my coverage:
image

Here's TestProject1-fcc-mscodecoverage-generated.runsettings:
TestProject1-fcc-mscodecoverage-generated.runsettings.txt

@tonyhallett
Copy link
Collaborator

I recognized that when I received ms coverage I hadn't included the test project so I ran again. Bizarrely, I cannot get any coverage today with any configuration.

Anyway, at least you can proceed with Coverlet.

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