單元測試—-CppUnit

來源:互聯網
上載者:User

下載CppUnit

從這裡下載http://sourceforge.net/projects/cppunit/
,解壓如下:

  • src:原始碼
  • lib:編譯好的庫
  • include:標頭檔
  • examples:例子
  • doc:說明文檔
  • contrib:他人貢獻的外圍代碼
  • config:設定檔

 

編譯

在src/目錄下, 將CppUnitLibraries.dsw工程檔案用vc 開啟。執行build/batch build,編譯通過以後, 在lib/目錄下,會產生若干lib,和dll檔案, 都以cppunit開頭. cppunitd表示debug版, cppunit表示release版(中途或者會有些project編譯失敗,一般不用管它)。其中項目cppunit為靜態庫,cppunit_dll為動態庫,產生的庫檔案為:

  • cppunit.lib:靜態庫release版;
  • cppunitd.lib:靜態庫debug版;
  • cppunit_dll.lib:動態庫release版;
  • cppunitd_dll.lib:動態庫debug版;

另外一個需要關注的project是TestRunner,它輸出一個dll,提供了一個基於GUI 方式的測試環境,在CppUnit下,
可以選擇控制台方式和GUI方式兩種表現方案。兩種方案分別如所示:

控制台方式:

GUI方式:

 

設定

 

要使用CppUnit,還得設定好標頭檔和庫檔案路徑,選擇Tools/Options/Directories,在Include files和Library files中分別添加%CppUnitPath%include和%CppUnitPath%lib,其中%CppUnitPath%表示CppUnit所在路徑。

TestRunner.dll為我們提供了基於GUI的測試環境。為了讓我們的測試程式能正確的調用它,最簡單的方法是在作業系統的環境變數Path中添TestRunner.dll的路徑。

使用

具體請看:http://www.vckbase.com/document/viewdoc/?id=1762

               http://www.vckbase.com/document/viewdoc/?id=1258

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.