Has anyone ever used gtest with visual studio? if so, how did you get code coverage reports? I'd like to configure my project to produce coverage data, but it seems like nobody else uses gtest/visual studio with gcov or any other code coverage.
I asked around the office, and someone suggested this tool: https://github.com/OpenCppCoverage/OpenCppCoverage
I will give it a try. I will come back and report the results.
Related
I am making changes to an existing code base and ran Visual Studio Code Coverage tool to obtain code coverage against all tests in the test project. I see that areas that have code coverage are highlighted. However, is there an easy way to find which test provided coverage for a portion of code?
Visual Studio CodeLens provides a feature called Associated Unit tests which shows all unit tests associated with the method. This was what I was looking for.
I have a solution in Visual Studio 2013 (c# code) that has a reference to a third-party assembly that I added with NuGet (ICSharpCode.SharpZipLib). When I run the "Code Analysis" on the solution I get lots of warnings coming from the third-party assembly. How do I tell VS that I only want code analysis advice from my code?
I'm pretty sure the errors are coming from the library itself and not my usage of it. There are a total of 32 issues e.g.
CA2237: Mark ISerializable types with SerializableAttribute.
I am using ILMerge to bundle into a single executable do you think that has confused the code analysis?
There is no way to tell FxCop to ignore namespaces or types in your code if it lives in the same binaries. When using ILMerge, the SharpZipLib essentially becomes part of your code, as it's merged into your assembly.
To get proper results, run FxCop on the assembly that's generated before the merge.
Other solutions will mention to put a [GeneratedCode] attribute on classes you want excluded, but IlMerge has no option to to that while merging, so that won't help you out.
In Visual Studio 2015 Code Analysis works on the source code using the new Roslyn Engine, which will solve the issue probably, as it does the analysis even before compilation and as such will not be impacted by your use of IlMerge.
Is there any way to feed visual studio static analysis on c++ code base into sonar?
Thanks
Did you check out the VSSonarExtension? Some hints on how to use it your can find here.
Update:
The other way around there may be a plugin by jmecosta called VSSonarAddin. One of its features is
"c++, runs local analysis with cppcheck and reports violations added
by local changes. "
You can find the project on github.
The Community C++ Plugin supports feeding compiler warnings as violations into SonarQube. You usually need to build your code with code analysis enabled and later you can use that data during SonarQube analysis. See here for more details!
I´m searching for a way to generate code coverage reports on VS2012 professional and using Nunit. I know that VS2012 ultimate have a code coverage tool and with Nunit_Adapter you can generate the code coverage report, but the issue is that I am using VS2012 professional and does not have the option to generate the code coverage report.
Does someone knows a plug-in or a relative simple way to creates this reports on VS2012 professional?
Thanks,
P.S And if someone knows a way to creates this reports using Nunit framework on VS2010 it could be an option.
Or if you want free (opensource) you can try OpenCover which is available as a nuget package and use ReportGenerator to generate some nice reports.
You'll need a third party code coverage tool, such as NCover or dotCover.
I have a Visual Studio 2010 .NET 4 solution with C# projects and a C++/CLI project.
I use Visual Studio's built in unit tests and code coverage.
Other than the fact that Visual Studio 2010 coverage tool for C++/CLI projects seems to be much weaker than Visual Studio 2008 coverage tool, I get weird results.
For example, I get uncovered code in this file:
c:\program files (x86)\microsoft
visual studio 10.0\vc\include\xstring
And some other files in that directory.
I want to exclude this code from coverage results.
Is there a way to put some exclude attributes on that code?
If not, is there a different automatic way to exclude that code from coverage? If not, is there a way to use EXCLUDE option to exclude it? Can it be done automatically within Visual Studio without running the coverage tool from command prompt?
Any other solutions?
Well, the MSDN documentation you linked to says:
EXCLUDE option is supported with code coverage.
To exclude all functions in a namespace use the wildcard character:
MyNamespace::*
Have you tried /EXCLUDE:std::* ? It sounds as if that would be the way to go.