天天看點

NAnt打包使用MSTest進行單元測試的配置

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 Files\Microsoft Visual Studio 8\Common7\IDE" />
<!--Location of compiled output (dll/exe) which contains MSTest-->
<property name="unittest.dll" value="&quot;c:\mytestproject\bin\Release\mytestproject.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>