CodeCoverage结果并转换为* .xml文件 [英] CodeCoverage results and converting to *.xml file

查看:310
本文介绍了CodeCoverage结果并转换为* .xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

当我们从VS Studio Tests(在TFS服务器上)转换代码覆盖率文件时,我们遇到了奇怪的问题。在coverage.coverage文件中我们有例如。包含块18和
未覆盖块1 的函数。使用动态代码覆盖率工具将其转换为* .xml文件(用于传递给SonarQube)后,它为我们提供了不同的值:覆盖块18,
未覆盖块9 。此输出在SonarQube统计信息中的代码覆盖率上具有较低的值。收敛到XML值之后的原因是什么?任何建议都会有所帮助。

We're getting weird issue when we're converting code coverage file from VS Studio Tests (on TFS Server). In coverage.coverage file we have eg. a function that has covered blocks 18 and uncovered blocks 1. After using the Dynamic Code Coverage Tools to convert it to *.xml file (for passing to SonarQube) it gives us different values: Covered blocks 18, uncovered blocks 9. This output casues low values on Code Coverage in SonarQube statistics. What is the cause that after convering to XML values are different? Any adviced would be helpful.

谢谢!

推荐答案

嗨Damian,

Hi Damian,

感谢您的帖子。

>>   VS Studio测试(在TFS服务器上)。

我不确定您是否在启用编码保护时添加了某些其他设置文件在TFS中,但显然,与DynamicCodeCoverage的结果相比,它错过了几个街区。   

I'm not pretty sure if you've added some other settings files when enabled coded coverage in TFS, but apparently, it missed several blocks compared to DynamicCodeCoverage's result.   

您可以参考以下内容:

1。验证您是否使用
,并指定了任何排除规则的排除规则

1. Verify if you are using a .runsettings file on TFS and have specified any exclusion rules that leave out your dlls from being instrumented

您可以使用自定义.runsettings文件运行您的UT使用DataCollectors节点中指定的Code Coverage配置。在代码覆盖率配置中,我们允许根据名称,公司名称,公钥令牌等排除dll。您可能会因
错误而排除所有DLL,或者错过包含您的任何DLL

You can run your UTs with a custom .runsettings file with Code Coverage configuration specified in the DataCollectors node. In the Code Coverage configuration we allow exclusions of dlls based on name, company name, public key token etc.You might have, by mistake, excluded all your DLLs, or missed including any of your DLLs here

修复.runsettings以获得不排除DLL的最小排除项或明确包含您想要覆盖的DLL。

Fix your .runsettings to have the minimal set of exclusions that do not exclude your DLLs OR explicitly include the DLLs you want coverage for.

2。检查二进制文件是否经历过任何形式的高级优化
,或者是否已通过vsinstr.exe等分析工具进行检测。

2. Check if the binary has undergone any form of advanced optimization or has been instrumented by a profiling tool like vsinstr.exe.

如果二进制文件已经由另一个分析工具进行检测或优化,例如。 vsinstr.exe我们跳过二进制文件,不包括它作为覆盖结果的一部分。

If a binary has already been instrumented or optimized by another profiling tool eg. vsinstr.exe we skip the binary and do not include it as a part of the coverage results.

无法获得此类二进制文件的代码覆盖率。

Code coverage cannot be obtained for such binaries.

实际上,建议关闭所有优化,并使用非优化的CHK构建运行代码覆盖率以获得最佳结果。

In fact, it is recommended to turn off all optimizations, and run code coverage with non-optimized CHK build to get best results.

参考链接:

https://blogs.msdn.microsoft.com/allendm/2012/06/05/troubleshooting-missing-data-in-code-coverage-results/

希望有所帮助。

祝你好运,

Fletcher


这篇关于CodeCoverage结果并转换为* .xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆