Code coverage not showing analysis

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    We are using below stack

Bitnami SonarQube Stack For Microsoft Azure

nunit3-console.exe

dotCover.exe (Version 2019.3.1)

  • what are you trying to achieve
    We have to push out code coverage data to SonarQube on Azure
  • what have you tried so far to achieve this
    Although the coverage files are getting generated it but not creating report.

Below is sample code for running coverage

$nunitexe = Resolve-Path "BuildTools\NUnit.ConsoleRunner.3.10.0\tools\nunit3-console.exe"
$dotcoverexe = Resolve-Path "BuildTools\JetBrains.dotCover.CommandLineTools.2019.3.1\tools\dotCover.exe"
& `
    $dotcoverexe `
        cover `
		--TargetExecutable="$nunitexe" `
        --Output="$OutputDir\TestResults\dotCover-results.html" `
        --ReportType=HTML `
		--Filters="+:module=*" `
		--LogFile="$OutputDir\dotCover.log" `
        -- `
		$Dlls `
        --where "cat !~ '($ExcludeTestCategories)'" `
        --result="$OutputDir\TestResults\NUnit-results.xml" `
        --out="$OutputDir\NUnit.stdout.log" `
        --agents=8

Below is the log data: -
10:06:00.254 DEBUG: Analyzing coverage after aggregate found ‘6’ coverage files.
10:06:00.254 DEBUG: Skipping ‘D:\TestProject\SampleApp\SampleApp\App_Start\RouteConfig.cs’ as it is a test file.
10:06:00.254 DEBUG: Skipping ‘D:\TestProject\SampleApp\SampleApp.Tests\Controllers\HomeControllerTest.cs’ as it is a test file.
10:06:00.254 DEBUG: Skipping ‘D:\TestProject\SampleApp\SampleApp\Global.asax.cs’ as it is a test file.
10:06:00.254 DEBUG: Skipping ‘D:\TestProject\SampleApp\SampleApp\App_Start\FilterConfig.cs’ as it is a test file.
10:06:00.254 DEBUG: Skipping ‘D:\TestProject\SampleApp\SampleApp\App_Start\BundleConfig.cs’ as it is a test file.
10:06:00.254 DEBUG: Skipping ‘D:\TestProject\SampleApp\SampleApp\Controllers\HomeController.cs’ as it is a test file.
10:06:00.254 DEBUG: The total number of file count statistics is ‘6’.
10:06:00.254 INFO: Coverage Report Statistics: 6 files, 0 main files, 0 main files with coverage, 6 test files, 0 project excluded files, 0 other language files.
10:06:00.254 WARN: The Code Coverage report doesn’t contain any coverage data for the included files.

Hello Sharad,

From the log messages, I see 10:06:00.254 DEBUG: Skipping ‘D:\TestProject\SampleApp\SampleApp\Controllers\HomeController.cs’ as it is a test file..
It seems your main files are classified as test files: that is why the coverage for these files is not imported into SonarQube.
From the logs, it seems you have 2 projects: SampleApp and SampleApp.Tests. What is the final name of the assembly for your SampleApp project ? Does it contain the word Test inside ? If yes, can you try to rename it to something else and try again. Otherwise, does your main project SampleApp have any dependency on unit test frameworks (such as Microsoft Visual Studio Test Platform, xUnit, NUnit) ? If yes, can you try to remove these dependencies from your main project and retry the analysis.

Let me know if one the above fixes the problem for you.

Best,
-Chris

Thanks Chris for your reply.

Unfortunately its not the case as i create this sample from Visual Studio boilerplate and not reference to NUnit or any other Test Framework is there.

Not even the resultant SampleApp dll has “Test” in it. And you are right somehow its considering the CS file as test file.

Regards,
Sharad

@skumar23 if you are using the Scanner for MSBuild v4.7 or later there will a message in the build log telling you why the project was categorised as a test project. See this wiki page for more information.

Regards,
Duncan