ncover 初次使用结果
参考如下文章,获知使用方式。
http://blog.csdn.net/haibo1228/article/details/4291890
ncover 版本 ncover-1.5.8
下载地址:http://downloads.ncover.com/ncover-1.5.8.zip
--------------------------------------------------------
测试代码如下:
c#代码
using system;
using system.collections.generic;
using system.text;
namespace ncover_helloworld
{
class program
{
public static string getdata_a()
{
return "00001";
}
public static string getdata()
{
return "hello world !";
}
static void main(string[] args)
{
console.writeline(args.length);
if (args.length > 0 && args[0].tolower() -- "a")
{
console.writeline(getdata_a());
}
else
{
console.writeline(getdata());
}
}
}
}
--------------------------------------------------------
测试结果如下:
c:\program files\ncover>ncover.console ncover_helloworld.exe a
ncover.console v1.5.8 - code coverage analysis for .net - http://ncover.org
copyright (c) 2004-2006 peter waldschmidt
command: ncover_helloworld.exe
command args: a
working directory:
assemblies:
coverage xml: coverage.xml
coverage log: coverage.log
waiting for profiled application to connect...connected
configuring profiler...
******************* program output *******************
1
00001
***************** end program output *****************
c:\program files\ncover>ncover.console ncover_helloworld.exe
ncover.console v1.5.8 - code coverage analysis for .net - http://ncover.org
copyright (c) 2004-2006 peter waldschmidt
command: ncover_helloworld.exe
command args:
working directory:
assemblies:
coverage xml: coverage.xml
coverage log: coverage.log
waiting for profiled application to connect...connected
configuring profiler...
******************* program output *******************
0
hello world !
***************** end program output *****************
--------------------------------------------------------
这里运行了两次,每运行完一次后,打开 coverage.xml 可查看到代码覆盖情况。
--------------------------------------------------------
有个问题,如果程序更加复杂,如何测覆盖率?
--------------------------------------------------------
另,只找到 1.0.1 的源码
http://nchc.dl.sourceforge.net/project/ncover/ncover/ncover-1.0%20rc2/ncover-1.0.1.zip