亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > cppUnit
cppunit helloworld詳盡篇
作者:網絡轉載 發布時間:[ 2012/11/29 15:08:08 ] 推薦標簽:

cppunit文檔真少。一個hellpworld程序折騰了好幾個小時才折騰夠。tnnd作者給的幫助那么幾句話。

偶結合折騰過程,寫一個更詳細點的helloworld。

系統:fc4,gclearcase/" target="_blank" >cc4

(1)下載
    到cppunit.sourceforge.net上下載源代碼。我的是cppunit-1.10.2.tar.gz。copy到/usr/src下。運行:
        tar -xf cppunit-1.10.2.tar.gz
    解壓縮。
(2)安裝
    進入cppunit-1.10.2目錄下。運行:
        ./configure; make; make check; make install
    安裝。make check有些項通不過。沒關系。:P
    .o, .a文件已經安裝到/usr/local/lib中去了,但頭文件沒安裝到/usr/include中去
(3)copy *.h文件
    把cppunit-1.10.2的cppunit目錄復制到/usr/include下
(4)撰寫mytest.cpp(從cppunit.sourceforge.net上copy下來的)
 1 #include <iostream>
 2
 3 #include <cppunit/TestRunner.h>
 4 #include <cppunit/TestResult.h>
 5 #include <cppunit/TestResultCollector.h>
 6 #include <cppunit/extensions/HelperMacros.h>
 7 #include <cppunit/BriefTestProgressListener.h>
 8 #include <cppunit/extensions/TestFactoryRegistry.h>
 9
10
11 class Test : public CPPUNIT_NS::TestCase
12 {
13   CPPUNIT_TEST_SUITE(Test);
14   CPPUNIT_TEST(testHelloWorld);
15   CPPUNIT_TEST_SUITE_END();
16
17 public:
18   void setUp(void) {}
19   void tearDown(void) {}
20
21 protected:
22   void testHelloWorld(void) { std::cout << "Hello, world!" << std::endl; }
23 };
24
25 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
26
27 int main( int argc, char **argv )
28 {
29   // Create the event manager and test controller
30   CPPUNIT_NS::TestResult controller;
31
32   // Add a listener that colllects test result
33   CPPUNIT_NS::TestResultCollector result;
34   controller.addListener( &result );       
35
36   // Add a listener that print dots as test run.
37   CPPUNIT_NS::BriefTestProgressListener progress;
38   controller.addListener( &progress );     
39
40   // Add the top suite to the test runner
41   CPPUNIT_NS::TestRunner runner;
42   runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
43   runner.run( controller );
44
45   return result.wasSuccessful() ? 0 : 1;
46 }
47
48
(5)編譯,運行
        有兩種方法
        (a) 鏈接靜態庫。編譯命令:
       g++ -L/usr/local/lib/libcppunit.a mytest.cpp -lcppunit -ldl -o mytest
       運行:
       ./mytest
       結果:
        Test::testHelloWorldHello, world!
         : OK
         (b) 鏈接動態庫。編譯命令:
       g++ mytest.cpp -lcppunit -ldl -o mytest
       運行時要先設置環境變量LD_LIBRARY_PATH到cppunit的安裝目錄,也是/usr/local/lib,命令如下:
       export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
       然后運行:
       ./mytest
       結果:
        Test::testHelloWorldHello, world!
         : OK

軟件測試工具 | 聯系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 黑人精品videossex黑人 | 亚洲天天看 | 午夜国产精品理论片久久影院 | 秋霞影视伦理手机在线观看 | 日本的黄色一级片 | 欧美成人精品第一区 | 大又黄又粗又爽妇女毛片 | 老子影院午夜伦不卡亚洲 | 99久久国产综合精品麻豆 | 国产高清一区二区三区 | 免费黄网站在线看 | 天天插天天操 | 国产性片在线 | 波多野结衣中文字幕在线播放 | 天天澡天天摸天天爽免费 | 午夜性爽快免费视频播放 | 国产香蕉国产精品偷在线观看 | 国产成人精品久久亚洲高清不卡 | 全黄性| 日本a在线视频 | 色狠狠综合网 | 超级碰碰永久免费视频播放 | 香蕉免费在线视频 | 欧美视频一区二区 | 久久国产影视免费精品 | 日日噜噜噜夜夜爽爽狠狠69 | 天天插在线视频 | 在线免费污视频 | 青草青草视频2免费观看 | 成人夜间视频 | 欧美成人免费全部观看天天性色 | 精品综合一区二区三区 | 色视频免费 | 免费簧网站永久在线播放国产 | 中文字幕禁忌乱偷在线 | 亚欧乱色一区二区三区 | 国产成人精品一区二三区在线观看 | 国产视频成人 | 日韩不卡手机视频在线观看 | 国产一区二区三区亚洲欧美 | 青娱乐伊人 |