2014-10-30 91 views
1

我已經在MVC中爲不使用NUnit的單元測試創​​建了測試項目。我可以在沒有NUnit的情況下使用NAnt運行測試項目

我可以用NAnt來運行這個項目嗎?

如果沒有什麼是自動運行測試用例的合適方法(如果可能的話)?

+0

你使用Visual Studio編譯這個測試項目? – Geddon 2014-12-22 22:31:54

+0

是@Geddon我正在使用VS13 – Twix 2014-12-29 04:56:29

回答

1

您不必使用NUnit。如果你已經在MVC中創建了一個單元測試項目,你可以使用命令行通過nant來運行它。

根據我的理解,您只需執行您的解決方案中爲您提供測試結果的單元測試項目。如果是這種情況,那麼你所需要做的就是使用msbuild命令行來運行該項目。如果你可以在命令行上運行任何東西,你可以在NAnt中做同樣的事情。

這是如何轉換爲NAnt。

例子:

<target name="run.unittest.project" > 
<property name="msbuild" value="C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"/> 
<property name="configuration" value="Debug" /> 

<exec program="${msbuild}" commandline="YourSolution.sln /p:Configuration:${configuration};Platform=OurPlatform /t:Project_Name"/> 

</target> 

但是....如果你想運行在NANT特定的組件,你可以試試這個NUint測試...

<target name="nunit.target" description="" >  

<property name="UnitTests" value="Path\project\bin\${configuration}" /> 

<echo message="Starting the UnitTests ....." /> 
<nunit2> 
    <formatter type="Plain" /> 
    <test assemblyname="UnitTests.dll" appconfig="UnitTests.dll.config" /> 
</nunit2> 
</target> 
+0

我不明白...你能否詳細解釋一下它? – Twix 2014-12-22 09:14:20

+0

查看編輯答案 – Geddon 2015-01-15 22:09:59

相關問題