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.
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'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.
Ok, so let's assume that I want to live according to the rule, treat your test code as carefully as your production code. How do I make Sonar and Stylecop analyze my test projects?
I've basically written this in my sonar-project.properties file:
#Core C# Settings
sonar.dotnet.visualstudio.solution.file=SomeSolution.sln
sonar.dotnet.excludeGeneratedCode=true
sonar.dotnet.version=4.0
sonar.donet.visualstudio.testProjectPattern=*.Tests
#StyleCop
sonar.stylecop.mode=
Reading the sonar build log I see that all projects except the tests (i.e. SomeTestProject.Tests) project are analyzed by Stylecop.
How can I make sonar+stylecop analyze my Tests project as well?
Seems this is unsupported in Sonar 3.3+C# plugin 2.0. To be fixed in 2.1
http://jira.codehaus.org/browse/SONARDOTNT-224?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
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.