Reputation: 3085
I would like to leverage visual studio code coverage ability out side Visual Studio as diagnostic test on environment without a Visual Studio instance on it.
I could not grab a tutorial or guideline on how it is done. So how it can be done? Even guidelines are good.
Upvotes: 0
Views: 537
Reputation: 114822
In Visual Studio 2012 or newer you can use the vstest.console.exe
to invoke tests to gather code coverage. the /enableCodeCoverage
commandline switch enables it.
You can gather coverage from a commandline using the older vsperfcmd
tool as well. This requires you to have at least a Visual Studio Test Agent installed on the machine. This is no full Visual Studio installation, but it contains teh components required to run tests and gather coverage details.
How to setup the VsPerfCmd
tool can be found here in this MSDN post. I copied the steps:
I assume you want code coverage on MyApp.exe
Open Visual studio command prompt
Add %ProgramFiles%\Microsoft Visual Studio 10\Team Tools\Performance Tools
to the path
set path=%path%;'%ProgramFiles%\Microsoft Visual Studio 10\Team Tools\Performance Tools'
CD to the folder that contains MyApp.exe
Instrument MyApp.exe for coverage:
vsinstr -coverage MyApp.exe
Start the coverage monitor to collect code coverage data:
vsperfcmd -start:coverage -output:MyApp.coverage
Run the instrumented MyApp.exe:
MyApp.exe
Shut down the monitor once MyApp.exe is done:
vsperfcmd -shutdown
Open the MyApp.coverage file in Visual Studio
With the Test Agent installed on the machine, you can also trigger a test run from Visual Studio (even if it is installed on a different machine).
Upvotes: 1