2
votes

I have Visual Studio 2012 solution that builds into a static library (.lib) (scons build is available partially) and tests for this code that are written using Google Test framework (compiled into .exe with its own main() function).

How can I get test coverage analysis for this solution from command line using Visual Studio 2012 built-in tools or any free VS2012-unrelated software?

1

1 Answers

2
votes

Finally I've managed to do this.

First you need to instrument *.exe files that are used to run Google tests (use /Exclude to avoid generating coverage for unwanted namespaces. as my investigation shows, '*' wildcard works in the end of statements only):

vsinstr.exe" mygtests.exe" /COVERAGE /Exclude:std::*

Note: You need to use vsinstr for proper architecture. Use full path in case you are not sure what kind of vsinstr is default

Then you need to start tests execution monitoring (Check architecture too):

VSPerfcmd.exe" /START:COVERAGE /OUTPUT:tests.coverage /cs /user:Everyone

After that run your *.exe file(s) as usual.

In the end of execution use the following to complete collecting of coverage:

VSPerfcmd.exe" -SHUTDOWN

You can now get coverage results in tests.coverage file.