Environment: Visual Studio 2013 Premium, Win7Ultimate, CodeCoverage.exe
Purpose: A code coverage report that excludes test project code that will later be converted to .coveragexml for reporting in SonarQube 5.1.
Annoyance I would not even know about this parsing error without adding the /verbose command to it. The only sign of failure was the .coverage file was no longer generated when I added the /config switch.
Working with files in the VS2013 IDE: The MyProject.runsettings file provides the expected output using Code Coverage Analysis in the IDE.
Menu: Test | Test Settings | Select Test Settings File... MyProject.runsettings Menu: Test | Analyze Code Coverage | All Tests
Trying to run the CodeCoverage.exe file to generate code coverage for my tests, I cannot use ANY *.runsettings files without errors:
"Error: Failed to parse configuration file <configfile>.runsettings"
Path Definitions:
codeCoveragePath = C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Dynamic Code Coverage Tools vstestpath = C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow myProjectOutputPath = assume correct since I get results when not using /config switch
Error getting start command (suppose paths are correct): Note. I do not show with the /verbose switch since I should not use it in the working environment
%codeCoveragePath%\CodeCoverage.exe collect /config:MyProject.runsettings /output:CoverageOutput.coverage %vstestpath%\vstest.console.exe %myProjectOutputPath%\MyClass.Tests.Unit.dll
Exe Works, if I DO NOT use the /config option . If I remove /config:MyProject.runsettings from the run command, I get a full report that includes a test project, but it lets me know that the rest of the command is correct, it just doesn't like the runsettings file.
I tried using the following examples:
Visual Studio 2013 script file without templates
MSDN file example
Completed empty file, no content: error
File with xml declaration only: error
File with only RunSettings Node declared: error
I even used troubleshooting tips from MSDN: no help.
MyProject.runsettings file:
<?xml version="1.0" encoding="utf-8"?> <RunSettings> <DataCollectionRunSettings> <DataCollectors> <DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <Configuration> <CodeCoverage> <ModulePaths> <Exclude> <ModulePath>.*\.Tests\.Unit\.dll$</ModulePath> </Exclude> </ModulePaths> </CodeCoverage> </Configuration> </DataCollector> </DataCollectors> </DataCollectionRunSettings> </RunSettings>
The file seems correct, based on the fact that the IDE will use it and generate the correct output in the "Code coverage results" window, reporting only the MyClass code, not the MyClass.Tests.Unit code.
I am sure that the command line CodeCoverage.exe does not like the / config option or another xml scheme is used.
Update
The work gives the result I want, I just canβt specify the file location for the next step
%vstestpath%\vstest.console.exe /Settings:MySettings.runsettings %myProjectOutputPath%\MyClass.Tests.Unit.dll
Doesn't work. Gives the exact opposite result that I want (only test.dll coverage in the report).
%codeCoveragePath%\CodeCoverage.exe collect /output:CoverageOutput.coverage %vstestpath%\vstest.console.exe /Settings:MySettings.runsettings %myProjectOutputPath%\MyClass.Tests.Unit.dll
We are looking for an answer.