ncover 与 NAnt 中的 nunit2 任务

发布于 2024-07-05 14:35:33 字数 75 浏览 7 评论 0原文

有机会得到这份工作吗? 我希望我的测试由 NAnt 中的 nunit2 任务运行。 另外,我想运行 Nover 而无需再次运行测试。

Is there any chance to get this work? I want my tests to be run by nunit2 task in NAnt. In addition I want to run NCover without running tests again.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

可爱咩 2024-07-12 14:35:33

我想到了。 您将 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" rel="nofollow noreferrer">http://www. jetbrains.net/confluence/display/TCD4/TeamCity+NUnit+Test+Launcher

I figured it out. You change the path of the NUnit launcher to that of TeamCity's own. Here is an example:

    <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/"
    />

As you can see, I have some of my own variables in there, but you should be able to figure out what is going on. The property you are concerned with is teamcity.dotnet.nunitlauncher. You can read more about it here at http://www.jetbrains.net/confluence/display/TCD4/TeamCity+NUnit+Test+Launcher.

女皇必胜 2024-07-12 14:35:33

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

I am having to do the same thing. I think the best we can hope for is to break open the NUnit jar file that comes with TeamCity and writing a custom task that integrates NUnit2 and NCover. I wish this wasn't so, but the NUnit2 task does not produce any visible output, so TeamCity is obviously not reading StdOut for the test results.

冷清清 2024-07-12 14:35:33

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

Why not have NCover run NUnit? You get the exact same test results. Also, what exactly are you trying to measure when running NCover outside of the tests? There's other ways to find stale or unreferenced code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文