NAnt打包使用MSTest进行单元测试的配置

NAnt比较老的持续集成工具了,对于它的文章都停留在09年左右的,只有一些github上的老项目上可以很多的看见是使用这个进行集成的,估计这个当时老外用的非常多吧。

如题,NAnt如果使用单元测试,用的最多的应该是NUnit,但是VS中新建的测试项目默认的就是MSTest,如果在使用过程中,没有指定MSTest的路径和依赖库,那么编译的时候就会报错,提示无法找到依赖。

想要解决的思路:1、指定依赖项目的路径。2、执行使用exec进行执行。

以下是我收集的资料:

http://codeissue.com/issues/i34dfa312fb52e7/how-to-execute-my-net-mstest-unit-test-from-nant-script-during-automated-build

最后附上配置节点:

<!--Visual Studio installation location-->
<property name="devenv.dir" value="C:Program FilesMicrosoft Visual Studio 8Common7IDE" />
<!--Location of compiled output (dll/exe) which contains MSTest-->
<property name="unittest.dll" value="&quot;c:mytestprojectinReleasemytestproject.dll&quot;" />
<!--Actual Task for executing MSTest unit test-->
<target name="ExecuteMSUnitTests" description="Execute unit tests using MSTest">
  <exec basedir="${devenv.dir}" workingdir="c:mytestproject" program="MSTest.exe" commandline="/testcontainer:${unittest.dll}" failonerror="true" />
</target>
原文地址:https://www.cnblogs.com/EasonJim/p/5794848.html