Xamarin Studio上的代码覆盖率 [英] Code coverage on Xamarin Studio

查看:79
本文介绍了Xamarin Studio上的代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可靠的工具可以帮助我们衡量单元测试的代码覆盖率?我主要在Xamarin项目中工作(在Xamarin Studio中)。



为了不堆积-1,我四处张望,但找不到成熟到足以可靠的东西。我不要求产品免费(但如果这样的话,那当然更好!)

解决方案

有代码Mono 4.x行中的coverage探查器(自2015年4月7日提交)。



如果您进行移动测试,但对您没有帮助在桌面平台上运行单元测试,您可以为Mono提供探查器选项:

 -profile = log:coverage 

coverage允许收集代码覆盖率数据
covfilter = ASSEMBLY将程序集添加到代码覆盖率过滤器
添加+以包括程序集或-排除程序集
filter = -mscorlib
covfilter-file = FILE使用FILE生成要过滤的程序集列表

在常规的 exe处理中,您最终得到:

 封面摘要:
xCorFlags(/ Users / administrator /monocov/lib/xCorFlags.exe)覆盖26%(42种方法) -覆盖11个)
< Module> ?%覆盖(0种方法-1种覆盖)
CorFlags.CorFlagsSettings 25%覆盖(4种方法-1种覆盖)
CorFlags.MainClass 50%覆盖(2种方法-1种覆盖)
CorFlags。 CommandLineParser 40%覆盖(20种方法-8覆盖)

因此,将配置文件选项传递给您的cmd行



获取详细的覆盖范围结果并完全集成到IDE(如VS)中。



,我对C#的OS-X / Linux所知甚少,甚至还没有Windows / .Net上可用的工具。 :-(



提交有关删除旧mono-cov和添加coverage Profiler的信息:



Git有关删除cov和添加日志覆盖率过滤器的日志信息:

  commit 16570265149730ec6a4760cc0fa34decc1a9d981 
作者:AlexRønnePetersen< alexrp @ xamarin.com>
日期:2015年4月7日星期二14:51:27 +0200
[profiler]删除旧的mono-cov分析器
我们将其替换为日志中的coverage支持

commit e91693fbb87f687a2fdb5a495c945c1872b3066c
作者:iain holmes< iain@xamarin.com>
日期:2015年2月27日10:13:54 +0000
[ cov]安装coverage过滤器


Is there a reliable tool that would help us measure the code coverage of my unit tests? I'm mostly working on Xamarin projects (in Xamarin Studio).

For the sake of not getting heaps of -1, I've looked around but couldn't find something mature enough to be reliable. I don't ask the product to be free (but it's of course better if it is ! )

解决方案

There is the code coverage profiler that is in the Mono 4.x line (since a April 7, 2015 commit).

It does not help you if you doing Mobile testing, but if you are running unit tests on desktop platforms you can supply the profiler options to Mono:

--profile=log:coverage

coverage             enable collection of code coverage data
covfilter=ASSEMBLY   add an assembly to the code coverage filters
                     add a + to include the assembly or a - to exclude it
                     filter=-mscorlib
covfilter-file=FILE  use FILE to generate the list of assemblies to be filtered

In normal "exe" processing, you end up with:

Coverage Summary:
    xCorFlags (/Users/administrator/monocov/lib/xCorFlags.exe) 26% covered (42 methods - 11 covered)
        <Module> ?% covered (0 methods - 1 covered)
        CorFlags.CorFlagsSettings 25% covered (4 methods - 1 covered)
        CorFlags.MainClass 50% covered (2 methods - 1 covered)
        CorFlags.CommandLineParser 40% covered (20 methods - 8 covered)

So, pass the profile options to your cmd line based runner (nunit, xunit, etc..) and you can get an overview of your coverage.

For detailed coverage results and fully integrated to a IDE (like VS), nothing I know about on OS-X/Linux for C# even comes close to the tools available on Windows/.Net. :-(

Commit Information on removal of old mono-cov and the addition of coverage profiler:

Git log info on cov removal and log coverage filter addition:

commit 16570265149730ec6a4760cc0fa34decc1a9d981
Author: Alex Rønne Petersen <alexrp@xamarin.com>
Date:   Tue Apr 7 14:51:27 2015 +0200
        [profiler] Remove old mono-cov profiler.
        We're replacing this with coverage support in the log profiler.

commit e91693fbb87f687a2fdb5a495c945c1872b3066c
Author: iain holmes <iain@xamarin.com>
Date:   Fri Feb 27 10:13:54 2015 +0000
        [cov] Install a coverage filter

这篇关于Xamarin Studio上的代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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