-
Notifications
You must be signed in to change notification settings - Fork 389
Data collection: Could not find data collector 'XPlat Code Coverage" #521
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
Comments
@vagisha-nidhi
If not supported can you specify when will be supported? |
In case of |
@vagisha-nidhi confirm that works.
|
@itsryankwon can you confirm that solution works for you? |
@itsryankwon any news? |
Close for stale feel free to re-open if needed. |
I'll do a mini followup, since I just tackled this (with your suggestions! @marco) For future readers. I was getting the error: Data collection: Could not find data collector 'XPlat Code Coverage" .... (everything below is in the context of using a LINUX build machine/image, not windows....there is a difference !!) So when you do a regular you'll get an output like this:
At this point, if you were to look in the directory:
you'll find NO "coverlet" dlls/files. examples: coverlet.core.dll What marco is saying here is "Yep, that's the issue, you don't have the magic dlls". So now if you "dotnet publish" your UNIT TEST (.csproj).... You will get something like this: (emphasis on the last directory in the chain of "publish")
Don't focus on the exact complete paths, focus that the "publish" directory has the necessary coverlet files. NOW, you run
Remember, "coverlet.core.dll" and "coverlet.collector.dll" won't show up by magic. I'll post my current (working) example below. Don't get too caught up in the versions (as long as they are not super old)...
The FluentAssertions and Moq are not important to "coverlet" code coverage........but they were in my file, so I posted them. The magic takeaway is
Thanks Marco ! Seeing coverage on the linux build image was awesome! Final documentation note: My "coverage" report came out at:
where "abcdabcd-abcd-abcd-abcd-abcdabcdabcd" is SOME RANDOM GUID. (the random guid subfolder is a different subject altogether, and is related to "dotnet test", NOT specifically this coverage collector.........and is outside the scope) Final helpful breadcrumb (windows vs linux) https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/dotnet-core?view=azure-devops scroll down to “If you're building on Linux or macOS,” This will give you some extra clues that "dotnet build", "dotnet test" and/or "dotnet publish" are not the exact same on linux. |
@granadacoder thank's for your explanation....one more thing you should use last version of test sdk with collector greather than 1.0.0 because there is a bug in vstest repo for old version
should be
You don't see any issue because your code doesn't suffer of a particular timing issue https://github.com/tonerdo/coverlet/blob/master/Documentation/KnownIssues.md#2-upgrade-coverletcollector-to-version--100 Collector guide https://github.com/tonerdo/coverlet/blob/master/Documentation/VSTestIntegration.md |
I wanted to share alternative to dotnet publish solution, which in some situations could be preferable, you can provide path to data collector as follows: |
FYI I am using MSBuild and I suffer from the same problem. I would build the tests before execution (using the MSBuild task) but the tests would not seem able to gather all the required files. But I happened to notice that for some reason it worked if I launched my script a second time without cleaning the outputs... |
msbuild integration uses this targets so it's also possible use part of it https://github.com/coverlet-coverage/coverlet/blob/master/src/coverlet.msbuild.tasks/coverlet.msbuild.targets |
This should really be part of the documentation. After many wasted hours I arrived to the same solution, and I wish I found this thread sooner. An additional tweak to this is to use <PackageReference Include="coverlet.collector" GeneratePathProperty="true" /> Though it's worth noting, that the property may not be available immediately, and can only be accessed from a target, e.g.:
|
@RussKie thanks for this info this should unblock me! |
In my case, on PC, firstly i run tests projects with installed coverlet.collector in Visual Studio (from Test Explorer), and after running |
I was missing the coverlet package reference in my .csproj in its entirety. Thanks @RussKie
|
Hello,
I can't show code due to it being for the company I work for but basically I am getting this error:
Data collection : Could not find data collector 'XPlat Code Coverage'
I saw this error on another post but I don't think my cause is the same.
What I'm doing to get this message:
dotnet vstest Tests.dll --collect:"XPlat Code Coverage"
ordotnet vstest Tests.dll --collect:"XPlat Code Coverage" --settings coverletArgs.runsettings
I tried using the runsettings file as well but that didn't change anything.
Output of dotnet --info:
I have the following package references as well in my test projects:
and
<TargetFramework>netcoreapp2.2</TargetFramework>
Am I missing something or doing something wrong?
The text was updated successfully, but these errors were encountered: