Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code coverage tool for Visual Studio TDD Project

My code is produced via Test Driven Development. My tools are Visual Studio 2010 express, Google Test, C++98 and the latest version of boost. I write my own Mock and am not using Google Mock.

What open-source tools would you recommend me so that I can establish my code coverage?

like image 244
Baz Avatar asked Nov 27 '12 14:11

Baz


People also ask

How do I get code coverage in Visual Studio?

On the Test menu, select Analyze Code Coverage for All Tests. You can also run code coverage from the Test Explorer tool window. Show Code Coverage Coloring in the Code Coverage Results window. By default, code that is covered by tests is highlighted in light blue.

Does Visual Studio code have code coverage?

Code coverage is a measurement of how many lines of code are executed when a unit test suite is executed. One of the most popular code coverage tools is the Visual Studio code coverage feature that comes with an enterprise flavor.

What is code coverage TDD?

The definition of TDD is that you don't write code without a failing test, and you do so in a tight loop that covers one branch at a time. So if you're doing TDD, any code you want to cover is ipso facto covered. If you're still getting defects, something else is wrong.

Which tool is used for code coverage?

Code coverage tools are available for many programming languages and as part of many popular QA tools. They are integrated with build tools like Ant, Maven, and Gradle, with CI tools like Jenkins, project management tools like Jira, and a host of other tools that make up the software development toolset.


1 Answers

I'm using gcov.

My setup is fairly complicated now that I'm having to think about describing it:
I've used the MinGW distro by stl, available at nuwen.net for gcc (g++) and gcov. This gives me some degree of portability.
I build my test application using scons and a batch file to build and run it to check it passes.

Then I commit code to version control and a Jenkins CI server running on my own machine picks it up, and still using scons, compiles it, but this time using the --coverage flag. It runs the test app, which this time outputs the *.gc?? files. Then I run gcov once, but telling it where all the files are, which produces loads of *.gcov files. I have in the past used the python script gcovr.py, but I've since written my own to scan all the *.gcov files and print all the lines not covered.

I'm not sure of the open-source status of all those pieces, but I know they are free.

like image 163
quamrana Avatar answered Sep 20 '22 16:09

quamrana