Closed eal61 closed 4 years ago
could be a dup can you try with https://github.com/tonerdo/coverlet/issues/72#issuecomment-399445565? add to test proj
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
No luck with that unfortunately. The reference to ReportViewer is about 3 levels down and the assembly is in the gac.. Realizing this is probably more of a dotnet build question(?) Running a dotnet build with more verbosity to hopefully get something more to work with.
Can you provide a simple repro that generates that issue?I'd like to go deep on this issue and understand well and maybe provide a solution.
I can try - I'll follow up on this in a bit!
Are you using this package? https://www.nuget.org/packages/Microsoft.ReportViewer.WebForms/ And can you attach you command line, how do you trigger test/coverage using msbuild?
Using an older version - 9.0.21022.227 It's a 2008 Redistributable version of Report Viewer, found here: https://www.microsoft.com/en-us/download/details.aspx?id=577
In our solution we run our tests through visual studio using xunit.runner.visualstudio.2.4.1 We do not currently collect test coverage stats in any form..
Working on a repro now!
Hi @MarcoRossignoli please check out my sample repro here: https://github.com/eal61/framework_reportviewer_repro
Sure I'll check asap and let you know!
Ok try this...tell to msbuild to move asm on target folder And after
D:\git\coverletissue\framework_reportviewer_repro (master -> origin)
λ dotnet test /p:CollectCoverage=true /p:Exclude=\"[Microsoft*]*,[xunit*]*\" /p:CoverletOutputFormat=cobertura
Esecuzione dei test per D:\git\coverletissue\framework_reportviewer_repro\A.Test\bin\Debug\A.Test.dll(.NETFramework,Version=v4.6.1)
Strumento da riga di comando per l'esecuzione di test Microsoft (R) Versione 16.3.0-preview-20190715-02
Copyright (c) Microsoft Corporation. Tutti i diritti sono riservati.
Avvio dell'esecuzione dei test in corso. Attendere...
L'esecuzione dei test è riuscita.
Totale test: 1
Superati: 1
Tempo totale: 1,8401 Secondi
Calculating coverage result...
Generating report 'D:\git\coverletissue\framework_reportviewer_repro\A.Test\coverage.cobertura.xml'
+--------+------+--------+--------+
| Module | Line | Branch | Method |
+--------+------+--------+--------+
| A | 100% | 100% | 100% |
+--------+------+--------+--------+
| B | 0% | 100% | 0% |
+--------+------+--------+--------+
| C | 0% | 100% | 0% |
+--------+------+--------+--------+
+---------+--------------------+---------------------+--------+
| | Line | Branch | Method |
+---------+--------------------+---------------------+--------+
| Total | 25% | 100% | 14,28% |
+---------+--------------------+---------------------+--------+
| Average | 8,333333333333334% | 33,333333333333336% | 4,76% |
+---------+--------------------+---------------------+--------+
We need to filter out Microsoft.ReportViewer.WebForms.dll
and xunit lib to avoid noise in warning(we skip to instrument dll with no local pdb).
You can also run coverlet as tool if you want e use every runner you need take a look to https://github.com/tonerdo/coverlet/issues/513#issuecomment-521180471
@eal61 news?
Your suggestion above fixes my build when I run dotnet build. When I run the dotnet test command it appears that the build finishes, but then code coverage isn't collected. Nothing is happening and when I cancel the process I get an error stemming from InstrumentationTask, similar to #340
Not sure why this is happening, especially since it seems that that issue should be resolved at this point with #370
**Clarification, sorry. Your suggestion worked perfectly for my repro that I attached. The issue I'm experiencing is just within my actual solution.
For context, here is the sequence of errors I'm getting. I'm not able to reproduce in the repro I attached earlier..
Build started, please wait... Build completed.
there is a long pause between these outputs, and then I attempt to kill the process
Attempting to cancel the build... Attempting to cancel the build... Attempting to cancel the build... Attempting to cancel the build... Attempting to cancel the build... Attempting to cancel the build... Attempting to cancel the build... Attempting to cancel the build... Attempting to cancel the build... Attempting to cancel the build... Attempting to cancel the build... Attempting to cancel the build... ^C ..\packages\coverlet.msbuild.2.6.3\build\coverlet.msbuild.targets(24,5): warning MSB4220: Waiting for the currently executing task "Coverlet.MSbuild.Tasks.InstrumentationTask" to cancel. [C:\source\Tests\Tests.csproj]
When I run the dotnet test command it appears that the build finishes, but then code coverage isn't collected.
Weird...I need to repro to understand what's happening...or you could try to enable logging https://github.com/tonerdo/coverlet/blob/master/Documentation/Troubleshooting.md#msbuild-integration
I can try to enable logging
I deleted the bin folder in my test project and re-ran the dotnet test command. All tests were run successfully, but the coverage report is empty. Ran with logging enabled and I'm looking at the binlog now
Do you have any recommendations on what to look for in the msbuild.binlog file? looking at the [coverlet] tagged messages but nothing is jumping out at me
Mmm [coverlet] it's ok...if file is empty and log doesn't report nothing about coverlet seem like no instrumentation at all happened...can you try to share command line and project structure?
currently using the suggested command from the troubleshooting page. opencover.coverage.xml is 1KB and it just reports zeroes across the board.
dotnet --info:
.NET Core SDK (reflecting any global.json): Version: 2.2.107 Commit: 2212cac826
Runtime Environment: OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.2.107\
Host (useful for support): Version: 2.2.5 Commit: 0a3c9209c0
.NET Core SDKs installed: 2.1.101 [C:\Program Files\dotnet\sdk] 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.503 [C:\Program Files\dotnet\sdk] 2.1.507 [C:\Program Files\dotnet\sdk] 2.2.107 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
command line: dotnet test C:\source\Console.Tests\Console.Tests.csproj -c debug /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include=[coverlet.] /p:Exclude=\"[Microsoft],[xunit]\" -verbosity:diagnostic -bl:msbuild.binlog -noconsolelogger`
output following: `C:\Program Files\dotnet\sdk\2.2.107\MSBuild.dll -noconsolelogger -nologo -bl:msbuild.binlog -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\2.2.107\dotnet.dllMicrosoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\2.2.107\dotnet.dll -maxcpucount -nodereuse:false -property:Configuration=debug /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:IncludeTestAssembly=true /p:Include=[coverlet.] /p:Exclude=[Microsoft],[xunit]* -restore -target:VSTest -verbosity:m -verbosity:quiet -verbosity:diagnostic C:\source\xfit\Console.Tests\Console.Tests.csproj Build started, please wait... Build completed.
Test run for C:\source\Console.Tests\bin\Debug\Console.Tests.dll(.NETFramework,Version=v4.6.1) Microsoft (R) Test Execution Command Line Tool Version 15.9.0 Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Total tests: 7. Passed: 7. Failed: 0. Skipped: 0. Test Run Successful. Test execution time: 4.2788 Seconds
Calculating coverage result... Generating report 'C:\source\Console.Tests\coverage.opencover.xml'
+--------+------+--------+--------+ | Module | Line | Branch | Method | +--------+------+--------+--------+
+---------+------+--------+--------+ | | Line | Branch | Method | +---------+------+--------+--------+ | Total | 100% | 100% | 100% | +---------+------+--------+--------+ | Average | ∞% | ∞% | ∞% | +---------+------+--------+--------+
tried with /p:IncludeTestAssembly=true as well (suggested in #516 ) and got the same output
It's hard understand without a repro 😞 you can reach me on gitter chat and we can try with remote support if you want.
@eal61 any news?
dotnet test C:\source\Console.Tests\Console.Tests.csproj -c debug /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include=[coverlet.] /p:Exclude="[Microsoft],[xunit]" -verbosity:diagnostic -bl:msbuild.binlog -noconsolelogger`
@eal61 why /p:Include=[coverlet.]
you don't have to instrument coverlet lib...can you try to remove and also upgrate to version 2.7.0
if you're using older one?
Close for stale conversation, feel free to re-open if needed.
Hi, I have a question/need for some general knowledge surrounding coverlets compatibility with .NET Framework.
I'm receiving an error when attempting to generate code coverage for a test project that references Microsoft.ReportViewer.WebForms. The error is occurring because coverlet is looking in the .NET Core sdk folder for the necessary dll, and it's not there. The assembly is present elsewhere. Please see the warning below. This precedes the build failure.
Do you have any recommendations for a graceful way to point coverlet towards non .NET Core referenced assemblies?
C:\Program Files\dotnet\sdk\2.2.107\Microsoft.CSharp.CurrentVersion.targets(134,9): warning MSB3884: Could not find rule set file "AllRules.ruleset". [C:\source\SSDirectoryLibrary44\SSDirectoryLibrary44.csproj] C:\Program Files\dotnet\sdk\2.2.107\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
Working in .NET 4.6.1 Xunit 2.4.1 coverlet 2.6.3