开发者

run nunit tests with TestCase Attribute from nant

开发者 https://www.devze.com 2023-04-03 19:59 出处:网络
i was using this nant task for my nunit tests. <nunit2 failonerror=\"false\"> <formatter usefile=\"true\"

i was using this nant task for my nunit tests.

<nunit2 failonerror="false">
  <formatter usefile="true"
             outputdir="build"
             type="Xml"
             extension=".xml"/>
  <test>
    <assemblies>
      <include name="Build/*.Tests.dll"/>
    </assemblies>
    <references >
      <include name="Tools/**/*.dll"/>
      <include name="Build/*.dll"/>
    </references>
  </test>
</nunit2>

It had the nice benefit that I could use it in multiple projects without changing anything. The problem is that it seems to be ignoring the TestCase and ExpectectException attributes on some of my tests causing them to fail. I've seen the suggestion to use the exec task to call nunit-console.exe, but then I have to spe开发者_运维百科cify all of the test dll's individually. Which means I can no longer use it in all of my projects without having to edit it. I'd all so have to edit it any time I add a test project to one of my solutions.

Is there any way to get the best of both worlds?


You can use <foreach> to run your tests:

<foreach item="File" property="test-assembly">
  <in>
    <items>
      <include name="${binaries-dir}/*" />
    </items>
  </in>
  <do>
    <exec program="${nunit.exe}" workingdir="${binaries-dir}"
        managed="true">
      <arg value="/nologo" />
      <arg value="${test-assembly}" />
    </exec>
  </do>
</foreach>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号