架构深渊

慢慢走进程序的深渊……关注领域驱动设计、测试驱动开发、设计模式、企业应用架构模式……积累技术细节,以设计架构为宗。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

NCover, MbUnit, CCNet

Posted on 2008-09-15 10:59  chen eric  阅读(425)  评论(0编辑  收藏  举报

NCover, MbUnit, CCNet

NCover and MbUnit play very nice togther, either from the command line, TD.net or ccnet.

From the command line its

ncover.console mbunit.cons.exe myassembly.dll

Don't forget the .exe, this assumes all the paths to the various thigs are mapped but if not

c:"program files"ncover"ncover.console.exe c:"program files"mbunit"mbunit.cons.exe myassembly.dll

If your using TD.net then simply use the right click and test with coverage option inside your unit test, it works just as well with MbUnit :)

If your using ccnet then you have a little more to do.

First alter your msbuild or nant file so that your unit tests are run from the mbunit.cons (using an exe task) and not the mbunit task. If your using MsBuild then its something like

<Exec WorkingDirectory="unitests"bin"debug"" Command="C:"Progra~1"NCover"ncover.console mbunit.cons.exe /rnf:unittest /rt:xml /rf:C:"CCNet"server"test"Artifacts unittests.dll //x C:"CCNet"server"test"Artifacts"ncover.xml" />

Note the working directory, this where your unittest assembly will be located. Note the use of progra~1 as program files is not undertsood by ccnet. Note that /rnf is the name of your unitest report and /rt: indicates its an xml file. Note that we use //x to output the ncover xml to the ccnet directory and /rf: to do the same for mbunit.

When thats working for you, edit your ccnet file to merge the outputs

 <merge>
         <files>
            <file>C:"CCNet"server"test"Artifacts"ncover.xml</file>
            <file>C:"CCNet"server"test"Artifacts"unittest.xml</file>
             <file>C:"CCNet"server"test"Artifacts"msbuild-results.xml</file>
         </files>
     </merge>