Skip to content
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

Coverlet not showing coverage of assembly which is part of another solution #1215

Closed
manishi2V opened this issue Aug 11, 2021 · 2 comments
Closed
Labels
waiting for customer Waiting for customer action

Comments

@manishi2V
Copy link

manishi2V commented Aug 11, 2021

I have a class library project named "MainProcessing" which contains my main code. This project is part of solution named "Processor". This class library project is written in .Net core 3.1.
I have another solution named "MainProcessing.Test" which contains a .Net core 3.1 class library project named "MainProcessingTest.Helper". I have added reference of MainProcessing.dll in this project.
This solution also contains unit test (MSTest) project named "Medical.Test" which contains reference of "MainProcessingTest.Helper" and "MainProcessing.dll". This project also written in .Net core 3.1 only.

I am using below mentioned command to run test cases and get code coverage results. But this command always gives me results of "MainProcessingTest.Helper" project instead of "MainProcessing.dll".

All code of "MainProcessing.dll" executed whenever I run unit test cases of project "Medical.Test" but it is not showing coverage results of my main project "MainProcessing.dll".

I want coverlet to show me results of only "MainProcessing.dll".

Command I use:
dotnet test 'Medical.Test.csproj' /p:CollectCoverage=true /p:CoverletOutputFormat=\"cobertura,lcov\" /p:CoverletOutput='Coverage/ProviderTestsCoverage' /p:Include=[*]MainProcessing.* /p:Exclude=[*]MainProcessing.Test* --logger:"trx;LogFileName=Logs/trxFile/ProviderTest.trx"

Current Output:

+-------------------+------+--------+--------+
| Module | Line | Branch | Method |
+-------------------+------+--------+--------+
| MainProcessingTest.Helper | 40% | 37.5% | 63.63% |
+-------------------+------+--------+--------+

+---------+------+--------+--------+
| | Line | Branch | Method |
+---------+------+--------+--------+
| Total | 40% | 37.5% | 63.63% |
+---------+------+--------+--------+
| Average | 40% | 37.5% | 63.63% |
+---------+------+--------+--------+

@petli
Copy link
Collaborator

petli commented Aug 11, 2021

How does the projects in MainProcessing.Test.sln access the MainProcessing project? I.e., is it a direct reference to the csproj in the source code of Processor.sln, or is the project built and published on e.g. an internal nuget with a package reference. In the latter case the coverlet instrumentor will likely not find some or all the sources on disk for MainProcessing, which it interprets as a third-party DLL that should be excluded from analysis.

You can try enabling loggin (https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/Troubleshooting.md) and see if the resulting log files (there are several) say something along the lines of

Unable to instrument module: MainProcessing.dll, pdb without local source files: ...

See e.g. #1164 and #1193 for discussions about this heuristic.

@MarcoRossignoli
Copy link
Collaborator

Closing for stale conversation, feel free to reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for customer Waiting for customer action
Projects
None yet
Development

No branches or pull requests

3 participants