Sonarqube & Dotcover - Coverage Metric is N/A or '-' - c#

I am running dotcover to generate a coverage report and then running that through sonarqube 5.0.1 (via Jenkins plugin). I used to have coverage metrics from previous runs, however, not sure what changed in build job / source code that now code coverage shows "-", even though all tests are successful (except 1 skipped). Not sure why this happens. Looking at the dotcover report generated - I can see the coverage, just not in sonar.
Pic:
Can anyone provide simple troubleshoot steps for this scenario?
Jenkins build log does not show any relevant error or exception.
Any insight on this will be much appreciated.
Thanks,

Related

SonarQube not able to record the coverage

I am using SonarQube 6.7 and TFS Plugin Sonar version 4.0.
Before the upgrade from of both the server and plugin I am able to get the coverage but now not no coverage is recorded from the MSTest. The same code with coverage is recorded when used with dot cover.
Sonar is able to record the number of tests and the coverage in TFS Build is also recorded yet it doesn't work. I have checked for the trx and the coverage files as well which is available but only *.coverage file is available not the coveragexml file. Is there any solution for this.
Seems to be the same issue as this one-- Code Coverage report is no longer imported
Try to use the workaround provided by Evangelink :
It seems like we have a regression on the Scanner for MSBuild (ticket:
https://jira.sonarsource.com/browse/SONARMSBRU-339).
While this ticket is being addressed you can fix this issue by simply
adding /d:sonar.cs.vscoveragexml.reportsPaths="**\*.coveragexml"
into the Additional Settings of the SonarQube Scanner for MSBuild -
Begin Analysis (new) task.
Just as you analyzed, with this command the .coveragexml will generated correctly and able to record the coverage.

Sonarqube code coverage with OpenCover

I'm currently using SonarQube 4.4 (latest) and I am trying to get a code coverage report for my c# project to appear.
I have the Unit Test Success showing but the Code Coverage simply shows as " - " like so:
Here is what I am doing: I am following the sonarqube example page: https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/csharp
I am running OpenCover and VSTest and configuring SonarQube to find the report.xml path under the CodeCoverage Configuration tab as well as configuring the Unit Test result paths.
From my understanding SonarQube no longer support Gallio, am I missing something?
Indeed, the C# plugin does not support Gallio anymore. But the latest versions support importing test result reports generated by tools like OpenCover.
Please read the "Code Coverage" documentation to know how to do this.

DotCover in TeamCity 8 doesn't work

I try to run dotCover with my NUnit tests, in the TeamCity 8 as a build step. But no metter what I try I always get the same error in the log file:
Step 4/4: Coverage (NUnit) (1s)
[Step 4/4] Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe #TeamCityImplicit
[Step 4/4] in directory: C:\TeamCity\buildAgent\work\6aee0f0d2626793d
[Step 4/4] ##teamcity[importData type='dotNetCoverage' tool='dotcover' file='C:\TeamCity\buildAgent\temp\buildTmp\coverage_dotcover3226256377023598081.data']
[Step 4/4] Importing data from 'C:\TeamCity\buildAgent\temp\buildTmp\coverage_dotcover3226256377023598081.data' with 'dotNetCoverage' processor
[Step 4/4] Rejected coverage report file: C:\TeamCity\buildAgent\temp\buildTmp\coverage_dotcover3226256377023598081.data size: 0. File is empty or does not exist
[Step 4/4] Process exited with code -2146232576
[Step 4/4] Step Coverage (NUnit) failed
I have tried to use both the included in TeamCity dotCover and the separately installed one, but both are failing with the same error.
My configuration:
If I choose no coverage tool, the tests work fine on its own. But with dotCover selected I always get the same error.
Any help here would be much appreciated.
Check out: http://confluence.jetbrains.com/pages/viewpage.action?pageId=49448495
In the case of internal TeamCity DotCover, you have to add the "ALL APPLICATION PACKAGES" read access rights to the TeamCity installation folder. If using an external DotCover, add the rights there.
This corrected the issue for me, for now.
It's probably because you are running this on build agent without .NET 3.5 (but with 4.0). It's easy to check because you will get exception just after running dotCover.exe on this agent. Install .NET 3.5 (using Server Manager in case of newest Windows).
The next thing is that there is another bug with dotCover in TeamCity 8. You need to use trial dotCover installation until they fix it (and put the path to installed dotCover into the build step configuration).
It solved the problem in my case.
Interestingly, for me at least, it worked for me once I disabled code coverage (i.e. un-selected an item in the .NET Coverage tool drop-down) and ran the build. When I re-enabled code coverage it worked (with no other changes to anything in TeamCity or on the build server). Weird!
I'm currently running TeamCity version 8.0.4 (build 27616).
This is similar to my issue, where the NUnit fails to run when dotCover is enabled.
I resolved this by setting .NET Runtime: Platform: as x86 in the configuration dropdown and I think the error is due to team city fails to figure out which is the correct platform.

How do I get TestDriven.net to generate a useful code coverage XML file with NCover?

Steps to Repro:
Make a C# project in VS 2010 Professional on Windows 7 Ultimate 32-bit edition.
Write some unit tests with the VS C# Unit Test wizard
Download and install the latest RTM or Beta version of TestDriven.Net.
Right-click on the testing project and select Test With NCover
Wait
See that NCover's window is empty
How do I get TestDriven.net to generate a useful code coverage XML file with NCover?
So far, I've tried rebooting, uninstalling the RTM version and installing the Beta version, and running in Debug & Release modes.
Update with Output window text:
------ Test started: Assembly: TestProject1.dll ------
NCover v1.5.8 - Code Coverage Analysis for .NET - http://ncover.com
NCover.Console v1.5.8 - Code Coverage Analysis for .NET - http://ncover.org
Copyright (c) 2004-2006 Peter Waldschmidt
Command: C:\Program Files\TestDriven.NET 3\ProcessInvocation86.exe
Command Args: "/assemblyName:TestDriven.TestRunner.Server, Version=3.2.2770.0, Culture=neutral, PublicKeyToken=50ecb853f8c6b8d2" "/xmlName:M:TestDriven.TestRunner.Coverage.NCoverCoverageTestRunner.OutOfProc.Run(System.String,System.String,System.String,System.String,System.String)" "/parameter:tcp://127.0.0.1:64445/7dbdb535-3602-4a8e-8bbc-f8be7eb83987" "/parameter:tcp://127.0.0.1:64445/fbff4f73-2438-43e4-b1f9-2bdaeb9c0907" "/parameter:C:\Users\Zian\Documents\Visual Studio 2010\Projects\ClassLibrary1\TestProject1\bin\Debug\TestProject1.dll" "/parameter" "/parameter"
Working Directory:
Assemblies: ClassLibrary1;ClassLibrary1_Accessor;TestProject1
Coverage Xml: C:\Users\Zian\AppData\Local\Temp\Mutant Design\TestDriven.NET 2.0\Coverage\ClassLibrary1\TestProject1.xml
Coverage Log: Coverage.Log
Waiting for profiled application to connect...Connected
Configuring Profiler...
******************* Program Output *******************
Unable to establish communications with the profiler. (0x2)
NCover couldn't create a coverage report.
(Assuming you are using NCover 1.5.8 which ship with TDD.Net)
I've done exactly what you described, and it works just fine...
Here are some things to consider:
Are you sure the actual xml file is empty? Try to look for it here:
C:\Users\USERNAME\AppData\Local\Temp\Mutant Design\TestDriven.NET
2.0\Coverage\YOURPROJECT, or use something like Everything (great free search tool) to find YourTestProject.xml. Perhaps there is a problem with the NCover GUI.
There have been some problems with MSTest & NCover integration prior
to 1.5.8. Try to reproduce this with NUnit and see what happens
(Actually IMHO, I don't see any advantage for MSTest over NUnit
anyway).
Are you running any other profiler in addition to NCover? Is
so, try to disable them.
EDIT:
Try to follow the steps in this article. There's a section called "NCover With TestDriven.NET".
It seems as NCover's profiler is not registered properly, so mainly what you have to do is remove it manually completely (TDD.Net probably doesn't do it for you), and only then reinstall it.
Uninstall the Beta version of TestDriven.net
Install the RTM version of TestDriven.net
The 2 steps work because NCover's profiler is not registered properly, as described by KiwiDude.

DotCover Not giving coverage for refrenced DLL

i donwloaded the dotcover 1.1.1 for evaluation.
We use a automation framework to run regression test where application 'X' refrences application 'Y's DLL .
I need code coverage of application Y when i run test through application 'X'.
But all i m getting is code coverage for app X!
This is not the case with other code coverage tool.
Could you please suggest where i may be going wrong?
DotCover doesn't support including referenced DLL's from command prompt for Code coverage yet( till 1.1.1).
Though Using DotCover GUI and unchecking "match with current project structure" option before starting Profiling for coverage allows coverage on referenced DLL's as well.
http://devnet.jetbrains.net/message/5277861?
This doesn't solve the problem as integration into automated testing framework cannot be achieved by using GUI.

Categories

Resources