程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> .NET實例教程 >> Visual Studio2005下配置及運行NUnit

Visual Studio2005下配置及運行NUnit

編輯:.NET實例教程
知道.Net下有個NUnit,一直沒有用它來寫程序。今天測試了下試試,寫點心得出來,一邊寫程序一邊還得測試,浪費了很多時間精力。代碼有了一定規模了,慢慢體會到單元測試的作用。用Nunit進行單元測試能及時發現新的Bug,保證原有的功能正常運行。而不必手工一個個的去試驗,這是很寶貴的。在NUnit的安裝目錄的bin下面有兩個config文件:nunit-gui.exe.config,nunit-console.exe.config,其中有一段startup的配置段,默認如下:
     <!--
     These statements specify the runtime versions supported
     in the order that they will be used if more than one
     is present. You can change the order of these if you like
     or remove any that do not apply.
 
  Since .Net 1.0 does not recognize the <supportedRuntime> elements,
  a <requiredRuntime> element is used in case it is the only version
  of the framework that is installed.
    -->
  <startup>
   <supportedRuntime version="v1.1.4322" />
   <supportedRuntime version="v2.0.40607" />
   <supportedRuntime version="v1.0.3705" />
   <requiredRuntime version="v1.0.3705" />
  </startup>

很明顯,NUnit就是通過這兒配置來支持不同的.Net版本的(VS2005 Beat1的版本是"v2.0.40607")。這篇blog的建議是將其他無關的配置項刪掉,it sure works,但是如果機器上同時安裝了多個版本,就需要來回修改這個config文件——顯然太麻煩。我是個懶人,有沒有更省事的方法呢?試了幾次,終於找到了,其實方法很簡單:只需要把最新的版本的一行配置項放到最上面就可以了:
<startup>
   <!-- make it top here -->
   <supportedRuntime version="v2.0.40607" />
   <!-- leave others -->
   <supportedRuntime version="v1.1.4322" />
   <supportedRuntime version="v1.0.3705" />
   <requiredRuntime version="v1.0.3705" />
  </startup>

簡單吧。測試了一下,機器上的另一個版本.Net(v1.1.4322)也可以同時運行了,但是"v1.0.3705"沒有測試,如果你是這一個版本,請告訴我你的測試結果 :)
注意的一點是根據你的工具不同(GUI或CONSOLE)配置不同的config文件.

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved