資源簡介
CppUnit測試是軟件開發過程中必不可少的一個部分,是軟件質量的保障的重要手段. 單元測試作為代碼級最小的單位的測試,在軟件開發過程中起著舉足輕重的作用。

代碼片段和文件信息
//?//////////////////////////////////////////////////////////////////////////
//?Implementation?file?ClockerListener.cpp?for?class?ClockerListener
//?(c)Copyright?2000?Baptiste?Lepilleur.
//?Created:?2002/04/19
//?//////////////////////////////////////////////////////////////////////////
#include?
#include?
#include?“ClockerListener.h“
#include?“ClockerModel.h“
#include?
ClockerListener::ClockerListener(?ClockerModel?*model
??????????????????????????????????bool?text?)
????:?m_model(?model?)
?????m_text(?text?)
{
}
ClockerListener::~ClockerListener()
{
}
void?
ClockerListener::startTestRun(?CPPUNIT_NS::Test?*test?
???????????????????????????????CPPUNIT_NS::TestResult?*eventManager?)
{
??m_model->setExpectedTestCount(?test->countTestCases()?*2?);
}
void?
ClockerListener::endTestRun(?CPPUNIT_NS::Test?*test?
?????????????????????????????CPPUNIT_NS::TestResult?*eventManager?)
{
??if?(?m_text?)
????printStatistics();
}
void?
ClockerListener::startTest(?CPPUNIT_NS::Test?*test?)
{
??m_model->enterTest(?test?false?);
}
void?
ClockerListener::endTest(?CPPUNIT_NS::Test?*test?)
{
??m_model->exitTest(?test?false?);
}
void?
ClockerListener::startSuite(?CPPUNIT_NS::Test?*suite?)
{
??m_model->enterTest(?suite?true?);
}
void?
ClockerListener::endSuite(?CPPUNIT_NS::Test?*suite?)
{
??m_model->exitTest(?suite?true?);
}
void?
ClockerListener::printStatistics()?const
{
??printTest(?0?““?);
??CPPUNIT_NS::stdCOut()??<?“\n“;
??CPPUNIT_NS::stdCOut()??<?“Total?elapsed?time:?“;
??printTime(?m_model->totalElapsedTime()?);
??CPPUNIT_NS::stdCOut()??<?“?average?test?case?time:?“;
??printTime(?m_model->averageTestCaseTime()?);
}
void?
ClockerListener::printTest(?int?testIndex
????????????????????????????const?std::string?&indentString?)?const
{
??std::string?indent?=?indentString;
??const?int?indentLength?=?3;
??printTestIndent(?indentString?indentLength?);
??printTime(?m_model->testTimeFor(?testIndex?)?);
??CPPUNIT_NS::stdCOut()??<?m_model->testPathFor(?testIndex?).getChildTest()->getName();
??CPPUNIT_NS::stdCOut()??<?“\n“;
??if?(?m_model->childCountFor(?testIndex?)?==?0?)
????indent+=?std::string(?indentLength?‘?‘?);
??else
????indent+=?“|“?+?std::string(?indentLength?-1?‘?‘?);
??for?(?int?index?=0;?index?childCountFor(?testIndex?);?++index?)
????printTest(?m_model->childAtFor(?testIndex?index?)?indent?);
}
void?
ClockerListener::printTestIndent(?const?std::string?&indent
??????????????????????????????????const?int?indentLength?)?const
{
??if?(?indent.empty()?)
????return;
??CPPUNIT_NS::stdCOut()?<“???“;
??CPPUNIT_NS::stdCOut()?<??CPPUNIT_NS::stdCOut()?<“+“??<?std::string(?indentLength?-1?‘-‘?);
}
void?
ClockerListener::printTime(?double?time?)?const
{
??CPPUNIT_NS::stdCOut()?<?‘(‘??<?ClockerModel::timeStringFor(?time?)??<?“s)?“;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2008-02-20?14:04??cppunit-1.12.1\
?????文件?????????286??2002-09-23?13:43??cppunit-1.12.1\AUTHORS
?????文件?????????129??2003-06-05?14:18??cppunit-1.12.1\BUGS
?????文件???????26430??2000-10-06?02:37??cppunit-1.12.1\COPYING
?????文件??????134056??2008-02-07?16:46??cppunit-1.12.1\ChangeLog
?????文件????????2249??2002-09-17?02:35??cppunit-1.12.1\CodingGuideLines.txt
?????文件????????9221??2001-07-07?01:48??cppunit-1.12.1\INSTALL
?????文件????????8596??2008-02-20?14:04??cppunit-1.12.1\INSTALL-WIN32.txt
?????文件????????3579??2004-04-10?02:41??cppunit-1.12.1\INSTALL-unix
?????文件????????2274??2007-01-12?12:39??cppunit-1.12.1\Makefile.am
?????文件???????28300??2008-02-20?13:59??cppunit-1.12.1\Makefile.in
?????文件???????41709??2007-01-27?14:25??cppunit-1.12.1\NEWS
?????文件?????????600??2001-10-29?10:13??cppunit-1.12.1\README
?????文件?????????902??2007-01-24?10:42??cppunit-1.12.1\THANKS
?????文件????????1219??2004-06-18?19:42??cppunit-1.12.1\TODO
?????文件??????271151??2008-02-20?13:59??cppunit-1.12.1\aclocal.m4
?????目錄???????????0??2008-02-20?14:04??cppunit-1.12.1\config\
?????文件????????5056??2001-06-17?23:47??cppunit-1.12.1\config\ac_create_prefix_config_h.m4
?????文件?????????739??2001-07-08?00:05??cppunit-1.12.1\config\ac_cxx_have_sstream.m4
?????文件?????????837??2001-09-20?12:18??cppunit-1.12.1\config\ac_cxx_have_strstream.m4
?????文件?????????717??2001-06-03?07:26??cppunit-1.12.1\config\ac_cxx_namespaces.m4
?????文件?????????998??2001-06-03?06:29??cppunit-1.12.1\config\ac_cxx_rtti.m4
?????文件?????????907??2001-06-03?07:26??cppunit-1.12.1\config\ac_cxx_string_compare_string_first.m4
?????文件????????1253??2003-05-08?04:07??cppunit-1.12.1\config\ac_dll.m4
?????文件????????1117??2004-02-19?04:45??cppunit-1.12.1\config\ax_cxx_gcc_abi_demangle.m4
?????文件?????????731??2007-01-27?12:19??cppunit-1.12.1\config\ax_cxx_have_isfinite.m4
?????文件????????1274??2007-01-12?12:24??cppunit-1.12.1\config\bb_enable_doxygen.m4
?????文件???????44892??2008-02-18?04:10??cppunit-1.12.1\config\config.guess
?????文件????????2621??2008-02-20?14:04??cppunit-1.12.1\config\config.h.in
?????文件???????33387??2008-02-18?04:10??cppunit-1.12.1\config\config.sub
?????文件???????17867??2008-02-10?10:55??cppunit-1.12.1\config\depcomp
............此處省略570個文件信息
評論
共有 條評論