-
Notifications
You must be signed in to change notification settings - Fork 387
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
VSTest with coverlet collector fails #993
Comments
Do you have net4x target framework on your projects? Can you try with the temporary version on my "debug" feed? https://f.feedz.io/marcorossignoli/coverletunofficial/nuget/index.json |
I added the Framework parameter - and now I am getting
|
The error above seem related to .NET Framework test process that tries to load .NET Core coverlet collectors. This is not supported in coverlet until version |
I used the nuget from the suggested feed https://f.feedz.io/marcorossignoli/coverletunofficial/nuget/index.json and I no longer see the exception. But now I have other errors with datacollector.exe (our tests create a kestrel process and we assert the response we get from an API endpoint)
|
Looking over #991 I realized that you don't support API tests (integration tests) coverage. And this will be released in |
Seems that there is an issue resolving one assembly Last error on |
Our app is a .NET Core application. The problem is that the system under test is an API which is hosted in kestrel. And this is not yet supported by coverlet. Do you have a release date for |
It depends, if the test process opens a port and there some call on it, should work. I mean a scenario like |
Our test process launches a dotnet process using
|
Ok if the process hosts instrumented assemblies should work..I mean if test keeps the process alive and shutdown at the end and the |
The test project has integration tests (that call a web application - which is hosted in IIS or Kestrel depending on a configuration). First question: Is IIS scenario supported? There is a configuration in .runsettings that allows to collect from childProcesses.
For Kestrel we start the process when the test starts. Something along this lines
When running we see no code coverage for the API's. |
Can you share
Will be supported but not through It's not related to host process it's related to instrumentation phase, I try to explain better how coverlet workflow works:
So it's not a problem the "host process" if Your use case is particular, I mean you do integration using a test framework(usually I mock server for instance using https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-5.0#aspnet-core-integration-tests). Anyway coverlet can collect hits from concurrent process and also with old app domain, so the only problem I see is a premature kill of process(if you kill after that |
Let me see if I got this right. If I have a .NET Core app hosted in IIS(w3wp.exe)/kestrel and I have a suite of integration tests I should be able to collect code coverage using coverlet (the preview version which support .netstandard targetframework) - because the IIS process has the dll&pdb and they are available for instrumentation - even if the IIS process was no started by the test process. I used the tracker logger but the file was not generated for the module I was interested in instrumenting (it's related to the amount of errors in diagnostics file). diag.host.20-11-27_11-09-50_76174_4.txt |
Ok thanks for help on investigation...I see only 2 asm instrumented
And a lot of resolution errors
Also I don't see in-process collector loaded(host log file). Are you able to provide a similar repo?I think it's a corner case and need to investigate further. |
Thanks for looking into it. I've attached a simplified example Scenario.zip that reproduces the issue. In
While creating the repo I realized that the test process is not aware of the dll that needs instrumentation (because it's an API and there is no direct reference in the test project). I am inclined to say that my scenario is not supported. And I don't think I can use |
Thanks for repro, I'll take a look asap. |
Hi @MarcoRossignoli, I too get the same error when I try to get coverage for my .netcore3.1 test project I have also added coverlet.collector and coverlet.msbuild version 3.1.0 as package reference on the unit test project,the .netcore test project has 2 .netstandard2.0 projects as reference, but didn't resolve it. &"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" --collect:"XPlat Code Coverage" netcoreapp3.1\UnitTest.dll /TestCaseFilter:"Name=TestName" Microsoft (R) Test Execution Command Line Tool Version 16.11.0 Starting test execution, please wait... |
@Manikandanmani I think that in your case the issue is that you didn't set the |
Hi @MarcoRossignoli, thanks for reaching out, after adding the test adapter path the xml report got generated, but the coverage results was empty, but for another .netcore3.1 test project reference a .netstandard2.0 project without specifying the test adapter path worked, but that too gave an empty coverage file. could you let me know how to generate coverage results correctly and why does without specifying the testadapterpath worked this project? |
Depends on how the compilation is done...sometimes collector is copied inside bin folder(publish for instance) in some other scenario not, so to be sure to always load it you should specify if you run with
can you provide a repro?It's hard without it. Usually we need a repro and the command line. |
@MarcoRossignoli , You were right, I forgot to inform that I executed dotnet publish command, after executing dotnet publish command and ran a test using vstest.console.exe without specifying the testAdapterPath executes the tests and gives the coverage.cobertura.xml, but even performing a dotnet publish or specfying the path and running the test using vstest the coverage.cobertura.xml shows zero code coverage, do have any idea what might be missed so it gave zero coverage as result. |
There're possible more causes, but I need a repro to understand what's happening, if you want to try yourself this is the way to enable and investigate what coverlet is doing https://github.com/MarcoRossignoli/coverlet/blob/master/Documentation/Troubleshooting.md#collectors-integration |
Hi @MarcoRossignoli, adding diag flag In vstest.console.exe /Diag:"Diag.txt" /Collect:"XPlat code coverage" UnitTest.dll /TestCaseFilter:"Name=Name" /TestAdapterPath:".nuget\packages\coverlet.collector\3.1.0\build\netstandard1.0" ran the test and generated empty results in coverage.xml, when viewing the *datacollector.txt it gave these
here both the files produced has empty results, when I added the runsettings file along with above command the test ran, but it didn't generate any coverage file. I refernced the coverlet.runsettings file from https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md, project packages , even tried dotnet pack and publish didn't work either.
|
@Manikandanmani can you take a look at every log starting with [coverlet] inside collector file log?You should see how many and what dll are instrumented for the coverage. |
This issue is stale because it has been open for 3 months with no activity. |
This issue was closed because it has been inactive for 275 days since being marked as stale. |
I have a .NETCore 3.1 test project with
"Microsoft.NET.Test.Sdk" 16.7.1
of and"coverlet.collector" 1.3.0
.I am getting an exception when running tests using VSTest (I can't switch to dotnet test approach, unfortunatly - there is a strong requirement to stick to vstest)
vstest.console.exe --collect:"XPlat Code Coverage" C:\Projects\test\Web.Tests\bin\Debug\Web.Tests.dll /TestAdapterPath:C:\.nuget\packages\coverlet.collector\1.3.0\build --Diag:"C:\Projects\diag.txt"
I get the following warning in the console:
And in diag.txt file I see:
I followed the discussion mentioned on microsoft/vstest#2278 but it seems like a separate issue.
It feels I am missing some type of configuration.
I can't figure out the source of the problem. Any help is highly appreciated. Thanks in advance.
The text was updated successfully, but these errors were encountered: