本文介绍了VS2013 CodeCoverage.exe运行设置文件从不解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 环境: Visual Studio 2013 Premium,W​​in7Ultimate,CodeCoverage.exe Environment: Visual Studio 2013 Premium, Win7Ultimate, CodeCoverage.exe 目标:代码覆盖率报告如下:不包括测试项目代码,以后再转换为.coveragexml以报告给SonarQube 5.1。Goal: Code Coverage Report that excludes test project code to later be converted to a .coveragexml for reporting to SonarQube 5.1. 烦恼我什至都不知道这个解析错误,而没有在命令中添加 / verbose 开关。我唯一的失败指示是添加 / config 开关时不再生成.coverage文件。 Annoyance I wouldn't even know of this parse error without adding the /verbose switch to the command. My only indication of a failure was the .coverage file was no longer being generated when I added the /config switch. 文件在VS2013 IDE中工作: MyProject.runsettings文件使用IDE中的分析代码覆盖率提供了预期的输出。File Works in VS2013 IDE: MyProject.runsettings file provides the expected output using "Analyze Code Coverage" in the IDE.Menu: Test | Test Settings | Select Test Settings File... MyProject.runsettingsMenu: Test | Analyze Code Coverage | All Tests尝试运行 CodeCoverage.exe 文件来生成测试的代码覆盖率我似乎无法使用任何 *。runsettings 文件而不会出现错误:Attempting to run the CodeCoverage.exe file to generate code coverage for my tests I can't seem to use ANY *.runsettings files without getting an error: "Error: Failed to parse configuration file <configfile>.runsettings"路径定义:codeCoveragePath = C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Dynamic Code Coverage Toolsvstestpath = C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindowmyProjectOutputPath = assume correct since I get results when not using /config switch运行命令收到错误(假设路径正确): 注意:自从我未显示 / verbose 开关Run Command receiving Error (assume paths are correct): Note: I'm not showing with /verbose switch since I shouldn't be using it under working conditions%codeCoveragePath%\CodeCoverage.exe collect /config:MyProject.runsettings /output:CoverageOutput.coverage %vstestpath%\vstest.console.exe %myProjectOutputPath%\MyClass.Tests.Unit.dll 如果我不使用 / config ,Exe会起作用选项:如果我从run命令中删除了 /config:MyProject.runsettings ,则会得到一份完整的报告,其中包括测试项目,但这让我知道该命令的其余部分是正确的,只是不喜欢runsettings文件。 Exe Works if I DON'T use the /config option If I remove the /config:MyProject.runsettings from the run command, I get a full report that includes the test project, but that let's me know the rest of the command is correct, it just doesn't like the runsettings file. 我尝试使用以下示例: Visual Studio 2013运行设置模板文件,无需修改 MSDN的示例文件 已完成的空白文件,无内容:错误Completed blank file, no content: error仅包含xml声明的文件:错误File with only the xml declaration: error具有xml声明的文件仅声明了RunSettings节点:错误File with only RunSettings Node declared: error我什至也使用了MSDN的故障排除提示:没有帮助。I've even used the Troubleshooting tips from MSDN, too: no help. MyProject.runsettings文件: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>基于IDE将使用该文件并生成正确输出的事实,该文件似乎是正确的在代码覆盖率结果窗口中,只需报告MyClass代码,而不报告任何MyClass.Tests.Unit代码。The file seems to be correct based on the fact that the IDE will use it and generate the correct output in the "Code Coverage Results" window by only reporting the MyClass code and not any MyClass.Tests.Unit code.我的意思是CodeCoverage.exe命令行不喜欢/ config选项,或者它使用其他xml架构。 I'm at the point that I think it is the CodeCoverage.exe command line doesn't like the /config option or it is using a different xml schema. 更新 Works 给出输出I想要,只是无法指定下一步的文件位置Works gives the output I want, just can't specify file location for next step%vstestpath%\vstest.console.exe /Settings:MySettings.runsettings %myProjectOutputPath%\MyClass.Tests.Unit.dll 不起作用给出我想要的完全相反的输出(仅报告中包含test.dll)。Doesn't Work Gives exact opposite output 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仍在寻找答案。推荐答案我相信您需要使用 / Settings:标志在 vstest.console.exe 的后面指定运行设置文件( I believe you need to specify the runsettings file at the back of the vstest.console.exe using the /Settings: flag (as opposed to the config flag of the CodeCoverage.exe).这样,您的命令就变成了CodeCoverage.exe的配置标志。 s:So that your command becomes: %codeCoveragePath%\CodeCoverage.exe收集 /output:CoverageOutput.coverage%vstestpath%\vstest。 console.exe %myProjectOutputPath%\MyClass.Tests.Unit.dll /Settings:MyProject.runsettings %codeCoveragePath%\CodeCoverage.exe collect /output:CoverageOutput.coverage %vstestpath%\vstest.console.exe %myProjectOutputPath%\MyClass.Tests.Unit.dll /Settings:MyProject.runsettings 这篇关于VS2013 CodeCoverage.exe运行设置文件从不解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-22 06:35