在NAnt中使用nunit2任务进行修复

时间:2008-09-04 15:22:18

标签: nunit nant task ncover

有没有机会获得这项工作?我希望我的测试由NAnt中的nunit2任务运行。另外我想运行NCover而不再运行测试。

3 个答案:

答案 0 :(得分:3)

我明白了。您将NUnit启动程序的路径更改为TeamCity自己的路径。这是一个例子:

    <mkdir dir="${build}/coverage" failonerror="false"/>

    <!-- run the unit tests and generate code coverage -->
    <property name="tools.dir.tmp" value="${tools.dir}"/>
    <if test="${not path::is-path-rooted(tools.dir)}">
        <property name="tools.dir.tmp" value="../../${tools.dir}"/>
    </if>

    <property name="nunitpath" value="${lib.dir}/${lib.nunit.basedir}/bin/nunit-console.exe"/>
    <property name="nunitargs" value=""/>
    <if test="${property::exists('teamcity.dotnet.nunitlauncher')}">
        <property name="nunitpath" value="${teamcity.dotnet.nunitlauncher}"/>
        <property name="nunitargs" value="v2.0 x86 NUnit-2.4.8"/>
    </if>

    <ncover program="${tools.dir.tmp}/${tools.ncover.basedir}/ncover.console.exe"
       commandLineExe="${nunitpath}"
       commandLineArgs="${nunitargs} ${proj.name.unix}.dll"
       workingDirectory="${build}"
       assemblyList="${proj.srcproj.name.unix}"
       logFile="${build}/coverage/coverage.log"
       excludeAttributes="System.CodeDom.Compiler.GeneratedCodeAttribute"
       typeExclusionPatterns=".*?\{.*?\}.*?"
       methodExclusionPatterns="get_.*?; set_.*?"
       coverageFile="${build}/coverage/coverage.xml"
       coverageHtmlDirectory="${build}/coverage/html/"
    />

正如你所看到的,我有一些自己的变量,但你应该能够弄清楚发生了什么。您关注的属性是teamcity.dotnet.nunitlauncher。您可以在http://www.jetbrains.net/confluence/display/TCD4/TeamCity+NUnit+Test+Launcher阅读更多相关信息。

答案 1 :(得分:2)

为什么不让NCover运行NUnit?您将获得完全相同的测试结果。另外,在测试之外运行NCover时,您究竟要测量的是什么?还有其他方法可以找到陈旧或未引用的代码。

答案 2 :(得分:0)

我必须做同样的事情。我认为我们所希望的最好的方法是打开TeamCity附带的NUnit jar文件,编写一个集成了NUnit2和NCover的自定义任务。我希望不是这样,但NUnit2任务不会产生任何可见的输出,因此TeamCity显然没有为测试结果读取StdOut。

相关问题