Google Test是Google C++ Testing Framework的一種非正式的稱謂,是google最近發布的一個開源C++測試架構。具有以下特點:
Google's framework for writing C++ tests on a variety of platforms (Linux, Mac OS X, Windows, Cygwin, Windows CE, and Symbian). Based on the xUnit architecture. Supports automatic test discovery, a rich set of assertions, user-defined assertions, death tests, fatal and non-fatal failures, type-parameterized tests, various options for running the tests, and XML test report generation.
Google的測試架構是在不同平台上(Linux,Mac OS X,Windows,Cygwin,Windows CE和Symbian)為編寫C++測試而產生的。它是基於xUnit架構的測試架構,支援自動探索測試,豐富的斷言集,使用者定義的斷言,death測試,致命與非致命的失敗,型別參數化測試,各類運行測試的選項和XML的測試報告。
更多可參考它的首頁:
http://code.google.com/p/googletest/
補充說明:
對比cppunit,boost.test,Google Test使用更加簡便。
cppunit的mfc輸出需要修改好些地方,標頭檔以及實現檔案均需要修改,並且在不同的地方使用不同的宏名稱,需要包含不同的標頭檔,比較繁瑣。
boost.test繼承boost庫的傳統,雖然沒有仔細使用過,但是從文檔中可以看到還是比較複雜的。
google test相對比較容易,可能為了符合JUnit移植過來的思想:程式員在最簡單的情況下就能夠使用JUnit,不用修改現有代碼,也不用去瞭解很多庫相關的內容以及語言特性。
google test的單元測試僅需要TEST()和TEST_F()兩個宏,真的佩服它的簡潔。