【问题标题】:ncover with nunit2 task in NAntncover 在 NAnt 中使用 nunit2 任务
【发布时间】:2008-09-04 15:22:18
【问题描述】:

有没有机会得到这份工作?我希望我的测试由 NAnt 中的 nunit2 任务运行。此外,我想在不再次运行测试的情况下运行 NCover。

【问题讨论】:

    标签: nunit nant task ncover


    【解决方案1】:

    我想通了。您将 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 阅读有关它的更多信息。

    【讨论】:

      【解决方案2】:

      为什么不让 NCover 运行 NUnit?你得到完全相同的测试结果。另外,在测试之外运行 NCover 时,您到底想测量什么?还有其他方法可以找到过时或未引用的代码。

      【讨论】:

        【解决方案3】:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2023-03-06
          • 1970-01-01
          相关资源
          最近更新 更多