曾经想在CruiseControl.Net上加入NCover和NCoverExplorer来输出测试案例覆盖代码的情况,当时因在Ncover.org上发现要$而作罢。

偶然获知其老版依然免费,心里痒痒,再次尝试。感觉CC的帮助写得不够完善,就来涂一篇。

 

配置CC项目

1 通过NCover调用NUnit做测试,就不需要在项目中其他地方再做一次了。NCover将在baseDirectory中生成Coverage.xml文件。

CruiseControl中应用NCover和NCoverExplore    <exec executable="D:\Studio\tools\NCover\NCover.console.exe" 
CruiseControl中应用NCover和NCoverExplore            baseDirectory
="D:\studio\"
 
CruiseControl中应用NCover和NCoverExplore            buildArgs
="D:\Studio\tools\nunit\nunit-console.exe /noshadow D:\studio\tests\bin\Release\MyTest.dll /xml:D:\studio\nunit-results.xml" />

 

2 接下来基于Coverage.xml生成NCoverExplore报告(CoverageReport.xml):

CruiseControl中应用NCover和NCoverExplore    <exec executable="D:\Studio\tools\NCover\NCoverExplorer.Console.exe" 
CruiseControl中应用NCover和NCoverExplore        baseDirectory
="D:\studio\" 
CruiseControl中应用NCover和NCoverExplore        buildArgs
="/x /r:4" />
CruiseControl中应用NCover和NCoverExplore    
</tasks>    

 

3 将NUnit、NCover和NCoverExplore的输出文件合并到本次集成的日志中(注意: merge节必须放在xmllogger之前):

CruiseControl中应用NCover和NCoverExplore<publishers>
CruiseControl中应用NCover和NCoverExplore    
<merge>
CruiseControl中应用NCover和NCoverExplore        
<files>
CruiseControl中应用NCover和NCoverExplore            
<file>D:\studio\nunit-results.xml</file>
CruiseControl中应用NCover和NCoverExplore            
<file>D:\studio\Coverage.xml</file>
CruiseControl中应用NCover和NCoverExplore            
<file>D:\studio\CoverageReport.xml</file>
CruiseControl中应用NCover和NCoverExplore        
</files>
CruiseControl中应用NCover和NCoverExplore    
</merge>            
CruiseControl中应用NCover和NCoverExplore    
<xmllogger logDir="log" />
CruiseControl中应用NCover和NCoverExplore
</publishers>        

 

配置Web DashBoard

1 在编译的总报告中加入NCoverSummaryNCoverExplorerSummary

    <buildReportBuildPlugin>
    <xslFileNames>
     <xslFile>xsl\header.xsl</xslFile>
     <xslFile>xsl\modifications.xsl</xslFile>
     <xslFile>xsl\compile.xsl</xslFile>
     <xslFile>xsl\compile-msbuild.xsl</xslFile>
     <xslFile>xsl\unittests.xsl</xslFile>
     <xslFile>xsl\fxcop-summary.xsl</xslFile>
     <xslFile>xsl\NCoverSummary.xsl</xslFile>
     <xslFile>xsl\NCoverExplorerSummary.xsl</xslFile>
     <xslFile>xsl\SimianSummary.xsl</xslFile>
    </xslFileNames>
   </buildReportBuildPlugin>  

  其输出如图:

CruiseControl中应用NCover和NCoverExplore
 
2 加入详细报告NCover.xsl 和 NCoverExplore.xsl

 

    <xslReportBuildPlugin description="NCover Report" actionName="NCoverBuildReport" xslFileName="xsl\NCover.xsl" />
    <xslReportBuildPlugin description="NCover Explore" actionName="NCoverBuildExplore" xslFileName="xsl\NCoverExplorer.xsl" />
    NCover.xsl 展示所有未调及的代码,其报告详细到代码行,爽!
    NCoverExplore.xsl展示一个直观的图形报告,如例:
CruiseControl中应用NCover和NCoverExplore
3 对了,别忘了重启IIS
NCover的使用
* 只有编译出PDB符号文件的库,NCover才能检测
* NCover排除测试案例: //ea NUnit.Framework.TestFixtureAttribute

相关文章:

  • 2021-06-25
  • 2021-06-28
  • 2021-10-13
  • 2021-05-15
  • 2021-11-09
猜你喜欢
  • 2021-10-03
  • 2021-05-23
  • 2021-11-24
  • 2021-06-01
  • 2021-10-28
  • 2022-01-14
相关资源
相似解决方案