Closed tavisca-vkapoor closed 4 years ago
What version of coverlet you want to use?It's not clear you said Coverlet Console version:- 1.7.2
but used dotnet test
command
The dotnet tool sample is https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/GlobalTool.md#code-coverage
Take a look at startup guide on coverlet flavours https://github.com/coverlet-coverage/coverlet#quick-start you can chose between msbuild integration(dotnet test
) .NET tool coverlet
and collectors --collect "XPlatCodeCoverage"
if you're on .NET Framework you should use msbuild integration or the .NET tool, next version of coverlet will support collectors also for .NET Framework applications.
Hey Marco,
Sorry for the wrong details Things i have used are below Coverlet.MsBuild:- 2.6.3 Framework Used:- .Net Core 2.1 Platform : Linux
I have also updated the details in original issue. remaining commands are correct and will remain same.
In the dotnet command, all the files are getting excluded except the cshtml files.
In the dotnet command, all the files are getting excluded except the cshtml files.
Coverlet instruments only dll assemblies...we cannot instrument any other file, what do you mean for "skip cshtml files"?
yes, you are right coverlet instruments only dll assemblies. And yes dll is getting generated for views. But when we run the code coverage command , module containing the front end files ( .cshtml ) is shown in the report with 0% coverage. Assembly name:- Demo.Services.Host Folder containing the frontend files:- Demo.Services.Host.Views
After running the command the output displayed:- +--------------------------------------------------+--------+--------+--------+ | Module | Line | Branch | Method | +--------------------------------------------------+--------+--------+--------+ | demo.services.host.Views | 0% | 0% | 0% |
how can we exclude the coverage shown for above module "demo.services.host.Views" containing frontend files.
I think you could use filtering like [demo.services.host.Views]*
Hey Marco, tried the command and working successfully. Thanks for helping out.
Glad to hear!
Hi I am having same issue i am not able to exclude Views- .cshtml from coverge My Folder sstructure in solution is .Web /Views- .cshtml files in the coverge result it is showing as AspNetCoreGeneraterDocumnet is 0 % . Please help which command should be used to exclude .cshtml pages
Hey Marco, tried the command and working successfully. Thanks for helping out.
Could you share the command line, please?
Coverlet.MsBuild:- 2.6.3 Framework Used:- .Net Core 2.1 Platform : Linux
Tried below commands
dotnet2.1 test csprojfilename /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --logger "trx;LogFileName=TestResults.trx" /p:ExcludeByFile="**/demo.services.host/Views/*/\.cshtml\"
dotnet2.1 test csprojfilename /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --logger "trx;LogFileName=TestResults.trx" /p:Exclude=\"[xunit.*]*,[demo.services.host..cshtml]\\"
After trying both the commands the output is still same as shown below +--------------------------------------------------+--------+--------+--------+ | Module | Line | Branch | Method | +--------------------------------------------------+--------+--------+--------+ | demo.services.host.Views | 0% | 0% | 0% |