How to trigger dotcover code coverage analysis on source build and generate report - dotcover

I am having main project file and testing project file.
when i build the solution i need to automatically trigger dotcover code coverage analysis and generate a report in html format.
It should happen in every build in visual studio.
I need suggestion regarding this to implement this in efficient way.
Thanks in advance.

If you use Visual Studio, you can add Post-build event command line.
Regarding to post build event, You can run dotcover coverage analysis from the command line. You can find related information in below links
how to add post build event to Visual Studio.
https://msdn.microsoft.com/en-us/library/ke5z92ks.aspx
How to run DotCover code coverage from command line.
https://www.jetbrains.com/help/dotcover/10.0/Running_Coverage_Analysis_from_the_Command_LIne.html

Related

Using Visual Studio to do Code Coverage on gtest unit tests for native VS C++

Friends,
I have been looking at unit test code coverage tools for the last 2 weeks, evaluating them for our specific needs. The last one I would like to evaluate is Visual Studio's own code coverage for native C++ unit tests. In our solution, we have the following:
full Visual Studio 2013 development environment with large projects
of multi-100 k lines of code
900+ unit tests already written in GTEST (working and executing in
the build process) and working in this environment native C++ code
(unmanaged)
a dozen projects in the solution or so
What I am trying to do is figure out
If I can use the Visual Studio code coverage Analysis tool to report results on my gtest unit tests
get code coverage results generated each time the unit tests or run (our unit tests are automatically run in a post-build step)
I have looked around these forums, MSDN and other sites (like stackoverflow) and I can't find a good source of guidance to making this combination of tools work. As I say, I have the solution, projects and unit tests running and working well, but to add code coverage I am not seeing how to do so using Microsoft's own Visual Studio code coverage.
I have already evaluated a few other packages like Software Verify, Semantic Designs, OpenCPPCoverage and Bullseye. I was hoping to try our Visual Studio's code coverage component since it is already part of our dev environment, but I can't seem to figure out how or if that will work.
Any help?
Thanks for any feedback, info you can give.
After searching more, I found that what I was missing was an adapter to run the tests in VS 2013. While my tests were executing as part of the build process, they weren't generating results in the Test Explorer because it wasn't being interfaced with Visual Studio's test explorer. This can be done simply by installing an extension. The extension I found that works well for us is GoogleTest Runner, which is found in the extensions library here:
GoogleTest Runner
I am leaving this question and answer here in case others have this same issue and need some help

SonarQube Visual Studio 2013 C++ Plugin

I have the following setup...
TeamCity 7.1.5
Visual Studio 2013
SonarQube 3.7.4
SonarQube C++ Community plugin 0.9.1
We have a number of Visual Studio C++ solutions / projects. They all process successfully through TeamCity - Compile, Unit Test, Nuget Package generation, etc. I am now trying to add the Sonar analysis of those project, using the C++ Community plugin.
Now I understand that the plugin itself does not perform any analysis, that must be done separately and the plugin only imports the results. The plugin is successfully able to identify and import all the Source files, I can seem them listed in within the SonarQube dashboard.
The actual build and analysis is done via Visual Studio / Visual C++ compiler using MSBuild. I have enabled Code Analysis via MSBuild and I can see that it is generating a list of issues. However, I cannot get SonarQube to import that list of issues.
For the MSBuild command I am using the following parameters...
/t:Build
/p:Configuration=Debug
/p:RunCodeAnalysis=True;CodeAnalysisRuleSet=AllRules.ruleset;verbosity=normal
/filelogger
/flp:verbosity=diagnostic
I have confirmed that a MSBuild.log file is being generated and it is finding issues.
The Sonar-Runner steps has the following options...
-Dsonar.language=c++
-Dsonar.projectKey=MYProject
-Dsonar.projectName=MYProject
-Dsonar.projectVersion=0.0.1
-Dsonar.sources=Src
-Dsonar.cxx.compiler.reportPath=*.log
-Dsonar.cxx.compiler.charset=UTF-8
-Dsonar.exclusions=**/packages/**/*
-Dsonar.cxx.includeDirectories=Src/Packages "
-Dsonar.cxx.compiler.parser='Visual C++'"
I have also tried using -Dsonar.cxx.compiler.reportPath=MSbuild.log
The Sonar appears to run fine, but just doesn't pick up the code analysis issues.
Could anyone please suggest what I could be doing wrong, or what else to try.
Any help would be greatly appreciated.
Thanks & Regards,
RG
try the last version of the plugin and make sure all compiler related rules are enabled in your profile. And check your compilation build log, if the paths are relative in there you need to pass /FC flag to the compilation

Visual Studio 2012 C++ code coverage merge executables

My c++ unit tests use gtest framework so every test is a separate executable. I'm running the CodeCoverage.exe tool to get the raw coverage data of each executable run. When I open the results in Visual Studio, each executable run appears in a separate branch and the results can't be merged together.
Is there any way to make this work?
One thing I've tried is to specify /session:uniq in the command line for both runs but that didn't have any effect.
Does it help you to capture via vsperfcmd.exe?
Build your gtest with /profile flag specified to the linker
Instrument your gtest exe with Visual Studio coverage instrumentation
vsinstr.exe gtest.exe /COVERAGE
Launch the code coverage capture tool
vsperfmon.exe /COVERAGE /OUTPUT:gtest.coverage
Run the gtest
Stop the capture tool
vsperfcmd.exe -shutdown
Launch the output file (gtest.coverage) to see the output in Visual Studio
OK, this should have been a comment, but I don't have the permissions yet.
You can run all your unit tests with the macro:
RUN_ALL_TESTS();

How can I disable code coverage / assembly instrumentation in Visual Studio 2012?

I have a project upgraded from Visual Studio 2010 to 2012 and the .testrunconfig file was included in the upgrade process.
I noticed that it was possible to click "Analyze code coverage" on any of the unit tests that I had run and it would correctly display the result. However, my test run configuration (originally from VS 2010) had code coverage disabled.
After doing a bit of research I learned that the VS 2010 configuration files have been deprecated and replaced by .runsettings files. It would appear that VS 2012 enforces assembly instrumentation by default which has a massive overhead associated with it.
Therefore, I would like to know how I can disable code coverage in VS 2012. Based upon my current findings it does not seem to be a trival task. One recent article I read had me creating an XML file manually and naming it "MYCONFIGURATION.runsettings" and manually manipulating XML attribute values.
Does anyone know how this should be done?
This is what I understand from your post:
You have a Test project with .testsettings file. You have not enabled code coverage in the test settings.
Code coverage instrumentation is not enabled by default in your scenario. Binaries will be instrumented if you do 'analyze code coverage' from VS.
Additional Info:
You can confirm that .coverage file is not generated by running the following command from visual studio developer command prompt:
vstest.console.exe /Settings:<your test settings file> test.dll
A coverage file will only get generated if you have enabled coverage in test settings.
Code coverage is only enabled through the Test Explorer using data driven adapters. The metadata for tests ran through the test explorer is almost completely different than that of tests ran straight from the unit test session window. Have you tried simply running it straight from the code (the MSTest gui bubbles) or from the unit test session window?

Automated tests on TFS 2010 using a test assembly file specification

I'm using TFS, it works fine. Now I want to add tests and code coverage. So I create a Local.testsettings. Running tests on my computer runs fine.
Configuration of the TFS Build is as follows:
- Automated test with test assembly file specification and the same test settings file (as recommended, instead of using a .vsmdi file)
When launching a build with TFS, my tests don't get executed :
Run MSTest for Test Assemblies
The MSTestActivity was invoked without a value for Platform or Flavor. The values Mixed Platforms and Debug were used.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe /nologo /usestderr /testSettings:"C:\Builds\1\MyProject\Sources\MyProject\Main\Source\MyProject\Local.testsettings" /searchpathroot:"C:\Builds\1\MyProject\Binaries" /resultsfileroot:"C:\Builds\1\MyProject\TestResults" /testcontainer:"C:\Builds\1\MyProject\Binaries\MyProject.Tests.Module1.dll" /maxpriority:"1" /minpriority:"1" /publish:"http://tfsserver:8080/tfs/Test" /publishbuild:"vstfs:///Build/Build/433" /teamproject:"MyProject" /platform:"Mixed Platforms" /flavor:"Debug"
Loading C:\Builds\1\MyProject\Sources\MyProject\Main\Source\MyProject\Local.testsettings...
Loading C:\Builds\1\MyProject\Binaries\MyProject.Tests.Module1.dll...
Starting execution...
No tests to execute.
There are no results to be published.
So it finds the assembly, but MSTest doesn't actually runs the tests.
Any hint is welcome.
Looking at this:
/maxpriority:"1" /minpriority:"1"
It looks like your priority criteria may be the problem.