我寫的文章不一定正確,如有任何錯誤或有問題地方,歡迎糾正。^^
Bookmark: HemiDemi MyShare Baidu Google Bookmarks Yahoo! My Web Del.icio.us Digg technorati furl Bookmark to:YouPush Bookmark to:你推我報

參考來源:http://squall.cs.ntou.edu.tw/cpp/91spring/CppUnitUsage.html

 

平常你寫完一個testcase

再測試程式地方就要加入

#include "ExampleTestCase.h"

CppUnit::TextTestRunner runner;
runner.addTest(ExampleTestCase::suite ());
runner.run();

如果覺得寫了N個TESTCASE 要寫N行include 跟 addTest 很煩的話 請參考以下方法 可以略過這2步驟

首先在ExampleTestCase.cpp 裡面加入

CPPUNIT_TEST_SUITE_REGISTRATION( ExampleTestCase);

然後執行測試裡面

runner.addTest改成

runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());

這樣他就會自己去抓所有 繼承CPPUNIT_NS::TestFixture 的測試案例  

好用東西

Posted by eric1300460 at 痞客邦 PIXNET Comments(1) Trackback(0) Hits(26)


open trackbacks list Trackbacks (0)

Comments (1)

Post Comment
  • 這個好!!!! 我還在想說怎們沒有這種東西@@

Comment Permissions: Allow commenting

Leave Comment

*Name/Nickname
E-mail
Personal Website
Comment Title
*Comment
* Private Comment