我正在尝试运行C#代码覆盖率结果导入但在最后一步得到错误。 我通过visual studio(TEST -Analyze Code Coverage- All Tests)创建了.coveragexml文件(名为test.coveragexml),并将其保存在项目目录中。 在CMD运行以下命令:
最后一步,我收到了这个错误:
10:09:29 AM ERROR: Error during Sonar runner execution
10:09:29 AM ERROR: Unable to execute Sonar
10:09:29 AM ERROR: Caused by: Error while parsing the XML file: D:\sTFS\24115\S
ources\SystemMapping\Source\test.coveragexml
10:09:29 AM ERROR: Caused by: Unexpected character '?' (code 65533 / 0xfffd) in
prolog; expected '<'
10:09:29 AM at [row,col {unknown-source}]: [1,1]
10:09:29 AM ERROR:
10:09:29 AM ERROR: To see the full stack trace of the errors, re-run SonarQube
Runner with the -e switch.
10:09:29 AM ERROR: Re-run SonarQube Runner using the -X switch to enable full d
ebug logging.
10:09:29 AM The sonar-runner did not complete successfully
Post-processing failed. Exit code: 1
找不到任何字符'?'在档案...... 来自日志:
M 10:09:29.021 INFO - Sensor org.sonar.plugins.csharp.CSharpSensor@5945ac done: 12370 ms
10:09:29 AM 10:09:29.021 INFO - Sensor org.sonar.plugins.csharp.CSharpCodeCoverageProvider$CSharpCoverageReportImportSensor@ed32df...
10:09:29 AM 10:09:29.104 INFO - Parsing the Visual Studio coverage XML report D:\sTFS\24115\Sources\SystemMapping\Source\test.coveragexml
10:09:29 AM 10:09:29.110 DEBUG - Release semaphore on project : org.sonar.api.resources.Project@101ba81[id=37975,key=SystemMapping,qualifier=TRK], with key batch-SystemMapping
10:09:29 AM INFO: ------------------------------------------------------------------------
10:09:29 AM INFO: EXECUTION FAILURE
10:09:29 AM INFO: ------------------------------------------------------------------------
10:09:29 AM Total time: 21.544s
10:09:29 AM Final Memory: 13M/121M
10:09:29 AM INFO: ------------------------------------------------------------------------
10:09:29 AM Process returned exit code 1
10:09:29 AM Creating a summary markdown file...
Process returned exit code 1
答案 0 :(得分:1)
最后我成功创建了代码覆盖率分析!
以下是我执行的命令(使用2个单元测试dll): D:\ SonarQube \ bin \ MSBuild.SonarQube.Runner.exe begin / k:MyProject / n:MyProject /v:1.0 /d:sonar.cs.opencover.reportsPaths=“D:\ SonarQube \ 6.5 \ NP \ MyProject \ Source \ opencover * .xml“/d:sonar.verbose=true
构建MyProject
“C:\ OpenCover \ OpenCover.Console.exe”-output:“D:\ SonarQube \ 6.5 \ NP \ MyProject \ Source \ opencover1.xml”-register:user -target:“C:\ Program Files( x86)\ Microsoft Visual Studio 12.0 \ Common7 \ IDE \ CommonExtensions \ Microsoft \ TestWindow \ vstest.console.exe“-targetargs:”D:\ SonarQube \ 6.5 \ NP \ MyProject \ Source \ MyProject.Test \ bin \ Debug \ MyProject .Test.dll“
“C:\ OpenCover \ OpenCover.Console.exe”-output:“D:\ SonarQube \ 6.5 \ NP \ MyProject \ Source \ opencover2.xml”-register:user -target:“C:\ Program Files( x86)\ Microsoft Visual Studio 12.0 \ Common7 \ IDE \ CommonExtensions \ Microsoft \ TestWindow \ vstest.console.exe“-targetargs:”D:\ SonarQube \ 6.5 \ NP \ MyProject \ Source \ MyProject.test \ bin \ Debug \ MyProject .test.dll“
D:\ SonarQube \ bin \ MSBuild.SonarQube.Runner.exe end&gt; log.txt
希望它能帮助别人:)
答案 1 :(得分:0)
目前尚不支持您的代码覆盖率报告格式(以<CoverageDSPriv>
开头):https://jira.sonarsource.com/browse/SONARNTEST-3
在此期间,请按照此页面上的说明获取在SonarQube中导入的Visual Studio代码覆盖率:http://docs.sonarqube.org/x/CoBh