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.
Related
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.
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
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.
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.
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.