首先说这篇主要参考了
http://build.sharpdevelop.net/ccnet/doc/CCNET/Using%20CruiseControl.NET%20with%20CppUnit.html
C++项目单元测试采用CPPUnit,CPPUnit的使用这里不详细讲了,有很多很不错的资料了。
在cppunit中设置输出xml文件名为Result.xml
服务器配置xml如下:
<project name="CppCal" queuePriority="1" >
<workingDirectory>E:/NetCruise/project</workingDirectory>
<artifactDirectory>E:/NetCruise/project/CppCal/buildinfo</artifactDirectory>
<category>Cpp Category</category>
<webURL>http://localhost/ccnet/server/local/project/CppCal/ViewProjectReport.aspx</webURL>
<modificationDelaySeconds>2</modificationDelaySeconds>
<triggers>
<intervalTrigger seconds="60"/>
</triggers>
<!--state type="yourStateManagerType" ..=""/-->
<sourcecontrol type="vss" autoGetSource="true" applyLabel="true">
<executable>C:/Program Files/Microsoft Visual SourceSafe/ss.exe</executable>
<project>$/CppCal.root</project>
<username>ccnetcpp</username>
<password>123456</password>
<ssdir>F:/MyVSS</ssdir>
<workingDirectory>E:/NetCruise/project</workingDirectory>
</sourcecontrol>
<!--labeller type="dateLabeller"/-->
<!--prebuild>
<yourFirstPrebuildTask ..=""/>
<yourOtherPrebuildTask ..=""/>
</prebuild-->
<tasks>
<devenv>
<solutionfile>E:/NetCruise/project/CppCal/CppCal.sln</solutionfile>
<configuration>Debug</configuration>
<buildtype>Build</buildtype>
<executable>C:/Program Files/Microsoft Visual Studio .NET 2003/Common7/IDE/devenv.com</executable>
</devenv>
<nunit>
<path>E:/NetCruise/project/CppCal/outPut/ProjectTest.exe</path>
<assemblies>
<assembly>*noassembly*</assembly>
</assemblies>
<outputfile>empty.xml</outputfile>
</nunit>
</tasks>
<publishers>
<merge>
<files>
<file>Result.xml</file>
</files>
</merge>
<xmllogger />
</publishers>
<externalLinks>
<externalLink name="google" url="http://somewhere/" />
<externalLink name="My Other Link" url="http://somewhere.else/" />
</externalLinks>
</project>
需要修改一个xls文件
下载地址
http://build.sharpdevelop.net/ccnet/doc/786491/unittests.xsl
需要替换文件,注意:这个连接下载下来是unittests.xml文件,需要手动改后缀名为xsl,然后替换
在本文中的位置是
E:/NetCruise/CruiseControl.NET/webdashboard/xsl/unittests.xsl
的文件。
这个文件是老外写的,用来能在CruiseControl.Net中显示CppUnit测试的结果,本来以为很厉害,但是打开以后研究了一下,发现还是比较简单的,有兴趣可以打开自己看看(配合CCNet生成的log**.xml文件)。
另外说一下这个Task,测试项目会生成一个exe,我们CPPUnit要用控制台那种,而且最终要以
return result.wasSuccessful() ? 0 : 1;
这种方式return,如果test成功他会返回0,CCNet如果发现程序返回0,那么表示测试成功,咱们的CCTray就是绿色的,如果返回1则相反,这样VC项目就会很好的进行构建。
<nunit>
<path>E:/NetCruise/project/CppCal/outPut/ProjectTest.exe</path>
<assemblies>
<assembly>*noassembly*</assembly>
</assemblies>
<outputfile>empty.xml</outputfile>
</nunit>