Code Coverage is ignoring some source files

Hi all,

We are using the Sonar Scanner, version 4.10.0 (but I’ve also tested with version 5.3.1 and the issue persists), on our GitHub pipeline to analyze our code and code coverage.

For one of our repos, some of the files are being ignored by SonarQube when doing the code coverage analysis even when we don’t have any ignore rule set on it.

I was trying to do some research on my own and after running locally on my machine I can see that there are 14 files being covered on the report.

But looking at the sonar scanner logs on GitHub Actions, I see that it’s only considering 7 files, as can be seen on the last line:

INFO: Found 7 MSBuild C# projects: 4 MAIN projects. 3 TEST projects.
INFO: Sensor C# [csharp] (done) | time=565ms
INFO: Sensor C# Tests Coverage Report Import [csharp]
INFO: Parsing the OpenCover report /github/workspace/./tests/Sharp.Menu.ElectricBoogaloo.Services.Tests/TestResults/_e50e512ea237_2021-10-07_15_19_14/In/e50e512ea237/coverage.opencover.xml
INFO: Adding this code coverage report to the cache for later reuse: /github/workspace/./tests/Sharp.Menu.ElectricBoogaloo.Services.Tests/TestResults/_e50e512ea237_2021-10-07_15_19_14/In/e50e512ea237/coverage.opencover.xml
INFO: Parsing the OpenCover report /github/workspace/./tests/Sharp.Menu.ElectricBoogaloo.Services.Tests/TestResults/de13895d-2588-4525-a796-4484aca5e280/coverage.opencover.xml
INFO: Adding this code coverage report to the cache for later reuse: /github/workspace/./tests/Sharp.Menu.ElectricBoogaloo.Services.Tests/TestResults/de13895d-2588-4525-a796-4484aca5e280/coverage.opencover.xml
INFO: Parsing the OpenCover report /github/workspace/./tests/Sharp.Menu.ElectricBoogaloo.Infrastructure.Tests/TestResults/de057c1f-4bb9-421f-9451-277d00bcf1fa/coverage.opencover.xml
INFO: Adding this code coverage report to the cache for later reuse: /github/workspace/./tests/Sharp.Menu.ElectricBoogaloo.Infrastructure.Tests/TestResults/de057c1f-4bb9-421f-9451-277d00bcf1fa/coverage.opencover.xml
INFO: Parsing the OpenCover report /github/workspace/./tests/Sharp.Menu.ElectricBoogaloo.API.Tests/TestResults/41d71e8c-2ac0-4d05-868b-d33b44a81169/coverage.opencover.xml
INFO: Adding this code coverage report to the cache for later reuse: /github/workspace/./tests/Sharp.Menu.ElectricBoogaloo.API.Tests/TestResults/41d71e8c-2ac0-4d05-868b-d33b44a81169/coverage.opencover.xml
INFO: Parsing the OpenCover report /github/workspace/./tests/Sharp.Menu.ElectricBoogaloo.Infrastructure.Tests/TestResults/_e50e512ea237_2021-10-07_15_19_00/In/e50e512ea237/coverage.opencover.xml
INFO: Adding this code coverage report to the cache for later reuse: /github/workspace/./tests/Sharp.Menu.ElectricBoogaloo.Infrastructure.Tests/TestResults/_e50e512ea237_2021-10-07_15_19_00/In/e50e512ea237/coverage.opencover.xml
INFO: Parsing the OpenCover report /github/workspace/./tests/Sharp.Menu.ElectricBoogaloo.API.Tests/TestResults/_e50e512ea237_2021-10-07_15_19_08/In/e50e512ea237/coverage.opencover.xml
INFO: Adding this code coverage report to the cache for later reuse: /github/workspace/./tests/Sharp.Menu.ElectricBoogaloo.API.Tests/TestResults/_e50e512ea237_2021-10-07_15_19_08/In/e50e512ea237/coverage.opencover.xml
INFO: Coverage Report Statistics: 7 files, 7 main files, 7 main files with coverage, 0 test files, 0 project excluded files, 0 other language files.

The 7 files that are on the Services project are being ignored.

I’ve ran some comparison with another project I’ve here and it seems to be working fine for that one:

INFO: Coverage Report Statistics: 165 files, 165 main files, 165 main files with coverage, 0 test files, 0 project excluded files, 0 other language files.

Can you please help me out on what might be causing this project/files to be ignored? I’ve ran through the .NET guideline a bunch of times and couldn’t find anything to help me out.

Thanks in advance!

Just to add here, when I ran a reporting tool locally, the coverage for those files is being considered.

Hi Lucas, welcome to the community :slight_smile:

Could it be that your services project is being considered as a test project?

You say that you have read through the .NET guidelines, do you mean this guide? If not that could be helpful.

Hope that helps, let me know how you get on

Tom

This topic was automatically closed after 10 days. New replies are no longer allowed.