I have seen some reports of this here, but they doesn't have any solutions due to inactivity, so I'll try again.
I have a test project using coverlet, but whenever I try to run either dotnet test /p:CollectCoverage=true or the coverlet command I get the following result and an empty coverlet file.
Test Run Successful.
Total tests: 47
Passed: 47
Total time: 1,3797 Seconds
Calculating coverage result...
Generating report 'XXXX'
+--------+------+--------+--------+
| Module | Line | Branch | Method |
+--------+------+--------+--------+
+---------+------+--------+--------+
| | Line | Branch | Method |
+---------+------+--------+--------+
| Total | 100% | 100% | 100% |
+---------+------+--------+--------+
| Average | NaN% | NaN% | NaN% |
+---------+------+--------+--------+
I have referenced both coverlet.collector and coverlet.msbuild packages in my project...
Any ideas why or suggestions how to find more information about the issue?
I actually got this on a another project this evening, and I did some brute-force comment/uncomment troubleshooting and I found the issue.
The solutions I have problem with has a Directory.Build.props file to keep common configuration for all projects within the solution. And in this file I have <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> since I am building NuGet packages with sourcelinking and this causes the problem. It should have a CI/CD condition which will fix it on my local computer, but that may still break coverlet in CI/CD builds? I haven't tested it so I don't know.
My guess is that this happens because of the path modifications done to the .pdb during build with this flag set to true?
since I am building NuGet packages with sourcelinking and
Source link is supported and also deterministic build(at the moment with some workaround) https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/DeterministicBuild.md
I have a test project using coverlet, but whenever I try to run either dotnet test /p:CollectCoverage=true or the coverlet command I get the following result and an empty coverlet file.
Can you enable also logging to understand if you're suffering of know issue(https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md#1-vstest-stops-process-execution-earlydotnet-test) or is related to some misconfiguration.
Logging guide https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/Troubleshooting.md#msbuild-integration
The DeterministicBuild suggestion for custom Target, so that solved my issue, thanks. Maybe add some comment somewhere that the NAN% issue may be related to that?
Do you still want logs for this issue, or shall we close this issue?
Do you still want logs for this issue, or shall we close this issue?
Close the issue pls
Maybe add some comment somewhere that the NAN% issue may be related to that?
Unfortunately is not the only reason, there are also other known issues https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md
Ok, closing.
@MarcoRossignoli Just spent whole day trying to figure out why Coverlet works locally and not when running on GitLab Actions. I guess this is great candidate for another "Known issue" - it didn't really strike me I should look into "Deterministic build", I was iterating over other pages, tried adding/removing arguments, even lost my confidence in putting together shell commands.
Anyway, @dozer75 thanks for pointing this out! 馃檱
I'll add to known issue!
@MarcoRossignoli added to docs (#948), I believe this could be enough for others to navigate to proper place in documentation. (Also adding apology for editor stripping trailing spaces, producing much weirder diff than expected - are you OK with that?)
@MarcoRossignoli Hi, I need your help. I try to solve this issue in my build but I can't do it even after 100 times. I read the documentation, known issues, all this stuff, but I still have NAN% and empty coverage file:

Here you can download binlog from GitHub Action run. I would be very grateful for your advice. I don't even know what to try anymore.
@sungam3r can you file a new issue(this was solved I forgot to close)?
Does it work in your local build(on your pc)?You should use collectors integrator(your project seem netcoreapp so it's fully supported) https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md
Most helpful comment
@MarcoRossignoli Just spent whole day trying to figure out why Coverlet works locally and not when running on GitLab Actions. I guess this is great candidate for another "Known issue" - it didn't really strike me I should look into "Deterministic build", I was iterating over other pages, tried adding/removing arguments, even lost my confidence in putting together shell commands.
Anyway, @dozer75 thanks for pointing this out! 馃檱