SonarQube not able to record the coverage - c#

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.

Related

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

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,

Running SonarQube without TFS Build?

I was asked to integrate another project (C#) into SonarQube. We use TFS 2013, SonarQube 5.1.2 with Sonar.MSBuild.Runner 1.0.
The Build process template is old (does not support pre and post Powershell scripts) and it is customized. Visual Studio 2013 is unable to edit the old build process template.
I tried to do just the static code analysis and run the MSBuild.SonarQube.Runner with the start parameter and a second time with the end parameter without doing a build in between (The code coverage does not seem important to them). But then I get the error "No ProjectInfo.xml files were found. Check that the analysis targets are referenced by the MSBuild projects being build"?
What options do I have to integrate this project into SonarQube?
To use the MSBuild SonarQube Runner from the command line, you have to:
Prepare the environment: MSBuild.SonarQube.Runner.exe begin /k:SQ_project_key /n:SQ_project_name /v:SQ_project_version (pick arbitrary SonarQube project key, name and version)
Run your build: msbuild
Upload analysis results: MSBuild.SonarQube.Runner.exe end
The MSBuild SonarQube Runner integrates with MSBuild and collects informations as it builds your project: You must run the build during the begin and end invocations, or this mandatory information won't be available and the MSBuild SonarQube Runner will fail with the message you reported. The MSBuild integration is compatible with MSBuild versions 4.0, 12 and 14.
Regarding the integration with TFS XAML builds, if you're using a customized one, you'll have to customize it a bit more to integrate the calls to the beginand end commands of the MSBuild SonarQube Runner.
Code Coverage is supported out of the box on TFS 2013 with the default build definition template, you just need to run tests with coverage enabled. If that doesn't work for you, see this link on how to manually pass the code coverage results path property: http://docs.sonarqube.org/x/CoBh

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.

Test Coverage with Sonar for .NET

I'm using Sonar 3.0.1 with the C-Sharp Plugins Ecosystem plug-in.
When running an analysis with the Simple Java Runner I don't receive any test coverage reports, instead Gallio prints the following error.
ERROR c.g.TestReportSensor - Source file not found for test report
This file means that if I have file Calc.cs and TestCalc.cs, Gallio cannot find the former and as a result cannot produce any coverage report.
I follow the default test project naming convention and Sonar easily qualify my test project as one.
Generally, such error means that the assemblies used by Gallio when executing the unit tests were not "freshly" compiled or moved out of the standard "bin/debug" folder before running Sonar.

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