c#(vs2005)中使用NUNIT (2.4.3)過程。
正在看《面向對象開發實踐之路C#》李維著。由於使用的開發工具與NUnit版本的不同,根據書中的說法與自己的實踐過程記錄下來。
1。下載NUNIT過程略去,這裏下載的是2.4.3的msi,安裝NUNIT完畢後,啓動vs2005C#環境。
2. 按照《面向對象開發實踐之路C#》中的例子建立PFMNUnitDemo.dll項目。
3。在項目“solution explore”-->“PFMNUnitDemo”(工程名稱)-->“references”點擊鼠標右鍵,出現菜單選擇"Add reference..." 添加nunit.framework.
4.vs2005 菜單項“project”--> "PFMNUnitDemo Properties..”(或者 xxxx工程名稱 Properties)-->"Debug"--->"start action"選擇"start external program"並輸入nunit2.4.3所在目錄之執行文件,這裏是C:/Program Files/NUnit 2.4.3/bin/nunit.exe
5.注意點:
a. "'Assembly Name' has no TestFixtures" 錯誤。在寫測試類時,不要忘了類前面加上public
b. "ArrayList問題" 將 using System.Collections.Generic; 改爲 using System.Collections;
c. "warning CS1591: Missing XML comment for publicly visible type or member....."問題。
屏蔽該告警的辦法:vs2005 菜單項“project”--> "PFMNUnitDemo Properties..”(或者 xxxx工程名稱 Properties)-->"Build"--->"Errors and warnings"--->"Suppress warnings"中填入1591即可,如果需要屏蔽多個warning,使用逗號分隔。eg : 1591,1592,1570