您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > cppUnit
CPPUnit在WIN32平臺安裝說明
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2013/3/15 14:42:04 ] 推薦標(biāo)簽:

[測試(Testing)]

        打開工作區(qū)文件examples/Examples.dsw。
        將CppUnitTestApp設(shè)為active project.
        為你要?jiǎng)?chuàng)建的庫選擇合適的配置。
        編譯運(yùn)行project。TestRunner GUI將會出現(xiàn)。

[庫(Libraries)]

        所有編譯后生成的庫均可在'lib'目錄中找到。多數(shù)庫可以在src/CppUnitLibraries.dsw工作區(qū)中創(chuàng)建。

lib:

cppunit.lib : CppUnit靜態(tài)庫“Multithreaded DLL”
cppunitd.lib : CppUnit靜態(tài)庫“Debug Multithreaded DLL”
cppunit_dll.dll : CppUnit動(dòng)態(tài)庫(DLL)“Multithreaded DLL”
cppunit_dll.lib : CppUnit動(dòng)態(tài)導(dǎo)入庫“Multithreaded DLL”
cppunitd_dll.dll : CppUnit動(dòng)態(tài)庫(DLL)“Debug Multithreaded DLL”
cppunitd_dll.lib : CppUnit動(dòng)態(tài)導(dǎo)入庫“Debug Multithreaded DLL”
qttestrunner.dll : QT TestRunner動(dòng)態(tài)庫(DLL)“Multithreaded DLL”
qttestrunner.lib : QT TestRunner導(dǎo)入庫“Multithreaded DLL”
testrunner.dll : MFC TestRunner動(dòng)態(tài)庫(DLL)“Multithreaded DLL”
testrunner.lib : MFC TestRunner導(dǎo)入庫“Multithreaded DLL”
testrunnerd.dll : MFC TestRunner動(dòng)態(tài)庫(DLL)“Debug Multithreaded DLL”
testrunnerd.lib : MFC TestRunner導(dǎo)入庫“Debug Multithreaded DLL”
testrunneru.dll : MFC Unicode TestRunner動(dòng)態(tài)庫(DLL)“Multithreaded DLL”
testrunneru.lib : MFC Unicode TestRunner導(dǎo)入庫“Multithreaded DLL”
testrunnerud.dll : MFC Unicode TestRunner動(dòng)態(tài)庫(DLL)“Debug Multithreaded DLL”
testrunnerud.lib : MFC Unicode TestRunner導(dǎo)入庫“Debug Multithreaded DLL”
TestRunnerDSPlugIn.dll : 注冊到你的VC++中的附加件。

        注意:當(dāng)你使用CppUnit DLL(cppunit*_dll.dll)時(shí),你必須連接相關(guān)的導(dǎo)入庫,并在project中定義預(yù)處理標(biāo)識CPPUNIT_DLL。

[使用CppUnit]

編寫單元測試:

        為了編寫單元測試,你需要連接cppunitXX.lib,此處的XX即所選配置對應(yīng)的后綴字母。 你必須在你的project中打開RTTI開關(guān)(Project Settings/C++/C++ Language)。 CppUnit的include目錄必須包含在include查找路徑中。你可以通過在Project Settings/C++/Preprocessor/Additional include directories或者Tools/Options/Directories/Include中添加include目錄做到這一點(diǎn)。

簡言之:

        打開RTTI開關(guān)
        連接lib/cppunitXX.lib
        include/ 必須包含在include查找路徑中


使用TestRunner GUI:
        為了使用GUI的test runner,你需要連接testrunnerXX.lib和cppunitXX.lib,此處的XX即所選配置對應(yīng)的后綴字母。 你必須在你的project中打開RTTI開關(guān)。 文件testrunner.dll必須位于你的應(yīng)用程序所在的路徑(Debug或Release目錄,project的dsp文件所在目錄,或環(huán)境變量PATH中所指定的目錄)。 一個(gè)簡單的辦法是,要么添加一個(gè)post-build命令,或者,將位于lib/目錄下的testrunner.dll添加到你的project中來,并定制創(chuàng)建步驟,將dll文件拷貝到你的“中間結(jié)果”目錄(通常是Debug或Release目錄)。

        因?yàn)門estRunner GUI是一個(gè)MFC的擴(kuò)展DLL,它能夠訪問當(dāng)前應(yīng)用程序的CWinApp。 參數(shù)設(shè)置將使用應(yīng)用程序的注冊鍵。這意味著,設(shè)置項(xiàng)“近使用的測試”對每個(gè)應(yīng)用程序而言都是不同的。

簡言之:

        打開RTTI開關(guān)
        連接lib/cppunitXX.lib和lib/testrunnerXX.lib
        include/必須包含在include查找路徑中
        為了運(yùn)行你的project,lib/testrunnerXX.dll必須可用


使用DSPlugIn:
        你必須在VC++中注冊該插件。在Tools/Customize/Add-ins and Macro files中點(diǎn)擊browse,并選擇lib/TestRunnerDSPlugIn.dll(你可以注冊release版或者debug版,都能運(yùn)行)。

        若VC++正在運(yùn)行,當(dāng)你雙擊一個(gè)failure后,VC++將打開相關(guān)文件并定位到出錯(cuò)行。

使用Test Plug In Runner:
        你的DLL必須導(dǎo)出(export)一個(gè)函數(shù),該函數(shù)實(shí)現(xiàn)了在include/msvc6/testrunner/TestPlugInInterface.h中所定義的接口。作為范例,參見examples/msvc6/TestPlugIn/TestPlugInInterfaceImpl.*。注意:該runner仍處于實(shí)驗(yàn)階段并未作足夠多的測試。

上一頁12下一頁
軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd