It is in a way quite easy to accomplish in your build script. The only catch is the complete lack of documentation. Benjamin Day led the way (he he - it rhymes).
What you need to do is two things:
- First configure the tests to run. This is easily done by adhering to good naming standards (all test assemblies ending with tests.dll). Then you can add create an item group called TestContainer, like below. This will run through all your tests.
<TestContainer Include="$(OutDir)\%2aTests.dll" />
- Secondly (and here is the secret) you need to specify that the tests are to be run under code coverage.
The easiest way to do this is to setup a .testrunconfig-file with Visual Studio. Such a file is always created for you (LocalTestRun.testrunconfig). If you double-click it and editor opens in which you can add code coverage. Do so and then save the file as another name, for example CodeCoverage.testrunconfig.
Finally add a property in your build script (in a property-group-item) which is called
RunConfigFile with the relative path to your CodeCoverage.testrunconfig. For example:
So as I said - not very hard (about two lines of code) but also very well hidden.
Published byon Last updated