FineCodeCoverage icon indicating copy to clipboard operation
FineCodeCoverage copied to clipboard

Hide/Remove Projects/Classes/etc. from coverage

Open mmmasent opened this issue 5 years ago • 14 comments

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

mmmasent avatar Jan 18 '21 02:01 mmmasent

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 ?

tonyhallett avatar Jan 21 '21 12:01 tonyhallett

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.

mmmasent avatar Jan 21 '21 22:01 mmmasent

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

tonyhallett avatar Jan 21 '21 23:01 tonyhallett

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?

wdspider avatar Feb 04 '21 00:02 wdspider

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>();
				});
	}
}

Nordes avatar Mar 09 '21 03:03 Nordes

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.

craigktreasure avatar Oct 25 '22 17:10 craigktreasure

@craigktreasure Is this only when using ms code coverage ?

tonyhallett avatar Oct 25 '22 17:10 tonyhallett

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

craigktreasure avatar Oct 25 '22 18:10 craigktreasure

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

tonyhallett avatar Oct 25 '22 19:10 tonyhallett

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.

craigktreasure avatar Oct 25 '22 19:10 craigktreasure

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 avatar Oct 25 '22 20:10 tonyhallett

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

tonyhallett avatar Oct 26 '22 16:10 tonyhallett

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

tonyhallett avatar Oct 31 '22 12:10 tonyhallett

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

craigktreasure avatar Oct 31 '22 17:10 craigktreasure