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

Hide/Remove Projects/Classes/etc. from coverage #67

Open
mmmasent opened this issue Jan 18, 2021 · 14 comments
Open

Hide/Remove Projects/Classes/etc. from coverage #67

mmmasent opened this issue Jan 18, 2021 · 14 comments
Assignees
Labels
custom report custom report feature

Comments

@mmmasent
Copy link

mmmasent commented Jan 18, 2021

Installed product versions

  • VS 2019 Community
  • Extension 1.1.63

Description

Unable to hide or remove coverage reports for unnecessary projects

Steps to recreate

  1. Run tests
  2. See code coverage report

Current behavior

Summary Code coverage for unit test projects are shown with calculations over entire solution

Expected behavior

Should be a way to hide/remove projects as needed and have coverage calculated only on desired projects fpr summary reporting
i.e. Right click project, select hide from coverage report

Additionally, it'd be good to have the ability to readd projects as desired, if one were to go project by project inside a solution

Side Notes

Awesome extension

@tonyhallett
Copy link
Collaborator

Unable to hide or remove coverage reports for unnecessary projects

The Exclude project element or Fine Code Coverage option is there for this reason. You can apply an exclusion attribute in a project as well.

Right click project, select hide from coverage report

We could do that but I don't think that it would be silent.

Additionally, it'd be good to have the ability to readd projects as desired, if one were to go project by project inside a solution

Are you thinking of an option - filter report by selected project. Then dependent upon the selected project in solution explorer we filter to only show that filter ?

@mmmasent
Copy link
Author

I understand fine code coverage is not ReSharper, but I am coming from a ReSharper background.
image

When you run code coverage with ReSharper, it also includes test projects in the code coverage, but you can exclude tests from the summary without needing an attribute of any kind. You can simply right click and click remove.

A filter of some kind would achieve what I am thinking of as well.

@tonyhallett
Copy link
Collaborator

You can exclude test projects with IncludeTestAssembly as a global visual studio option or on a project basis.

@wdspider
Copy link

wdspider commented Feb 4, 2021

Is there a way to get Fine Code Coverage to use the include/exclude settings I've already defined within my *.runsettings file instead of requiring them to be re-setup within Fine Code Coverage vs options?

@tonyhallett tonyhallett added enhancement New feature or request custom report custom report feature and removed enhancement New feature or request labels Feb 7, 2021
@tonyhallett tonyhallett self-assigned this Feb 26, 2021
@Nordes
Copy link

Nordes commented Mar 9, 2021

I simply use the [ExcludeFromCodeCoverage] over a class or method. If anyone was wondering how to do in C#.

{
	[ExcludeFromCodeCoverage] // <== this line
	public class Program
	{
		public static void Main(string[] args)
		{
			CreateHostBuilder(args).Build().Run();
		}

		public static IHostBuilder CreateHostBuilder(string[] args) =>
			Host.CreateDefaultBuilder(args)
				.ConfigureWebHostDefaults(webBuilder =>
				{
					webBuilder.UseStartup<Startup>();
				});
	}
}

@craigktreasure
Copy link

This appears to work at the class level, but not for methods. Methods marked with the ExcludeFromCodeCoverage attribute aren't excluded from the code coverage calculation.

@tonyhallett
Copy link
Collaborator

@craigktreasure
Is this only when using ms code coverage ?

@craigktreasure
Copy link

Hmmm...good question. Not sure. I have RunMsCodeCoverage set to No in the FCC settings.

@tonyhallett
Copy link
Collaborator

@craigktreasure
ExcludeFromCodeCoverage should work on methods. Do you have a repo that I can look at ?

@craigktreasure
Copy link

Not that I can quickly share. To be clear, what i'm seeing is that the Fine Code Coverage window doesn't properly reflect excluded methods. For that matter, it's the same for assemblies marked with ExcludeFromCodeCoverage.

The reports I generate using Coverlet are correct. It's just the Fine Code Coverage window that doesn't reflect properly.

@tonyhallett
Copy link
Collaborator

FCC uses Coverlet version 3.0.3 and a fork of https://github.com/danielpalme/ReportGenerator.

All cobertura files ( multiple test projects ) are merged into a single one by ReportGenerator and this is then used to generate the report in the Find Code Coverage tool window.

Perhaps you can compare your Coverlet report with the coberturas within

...YourProject\bin\Debug\net6.0\fine-code-coverage\coverage-tool-output

YourProject.coverage.xml is generated by Coverlet
Cobertura.xml is the merged version.

The issue could be the Coverlet version, now at 3.1.2, or ReportGenerator.
The next FCC release creates its own html report displaying it in a WebView2 control and as such can use the latest version of ReportGenerator which dropped support for ie and the WebBrowser control.

@tonyhallett
Copy link
Collaborator

@craigktreasure
If you can create a minimal reproduction I will have a look.

@tonyhallett
Copy link
Collaborator

@craigktreasure
Latest release updates Coverlet to 3.2.0.
Does this resolve your issue ?

@craigktreasure
Copy link

Yep. It does seem to have resolved the issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom report custom report feature
Projects
None yet
Development

No branches or pull requests

5 participants