2323#include " library.h"
2424#include " options.h"
2525#include " redirect.h"
26+ #include " timer.h"
2627
2728#include < algorithm>
2829#include < cstdio>
@@ -88,6 +89,7 @@ TestFixture::TestFixture(const char * const _name)
8889 : classname(_name)
8990{}
9091
92+ TestFixture::~TestFixture () = default ;
9193
9294bool TestFixture::prepareTest (const char testname[])
9395{
@@ -106,19 +108,24 @@ bool TestFixture::prepareTest(const char testname[])
106108 // Tests will be executed - prepare them
107109 mTestname = testname;
108110 ++countTests;
111+ std::string fullTestName = classname + " ::" + mTestname ;
109112 if (quiet_tests) {
110113 std::putchar (' .' ); // Use putchar to write through redirection of std::cout/cerr
111114 std::fflush (stdout);
112115 } else {
113- std::cout << classname << " :: " << mTestname << std::endl;
116+ std::cout << fullTestName << std::endl;
114117 }
118+ mTimer .reset (new Timer (fullTestName, ShowTime::TOP5_SUMMARY, timerResults));
115119 return !dry_run;
116120}
117121
118122void TestFixture::teardownTest ()
119123{
120124 teardownTestInternal ();
121125
126+ if (mTimer )
127+ mTimer ->stop ();
128+
122129 {
123130 const std::string s = errout_str ();
124131 if (!s.empty ())
@@ -385,6 +392,7 @@ void TestFixture::processOptions(const options& args)
385392 dry_run = args.dry_run ();
386393 exclude_tests = args.exclude_tests ();
387394 exename = args.exe ();
395+ timerResults = args.timer_results ();
388396}
389397
390398std::size_t TestFixture::runTests (const options& args)
@@ -410,7 +418,10 @@ std::size_t TestFixture::runTests(const options& args)
410418 tests = it->second ;
411419 }
412420
413- TestFixture* fixture = test->create ();
421+ TestFixture* fixture;
422+ Timer::run (test->classname + " - create" , ShowTime::TOP5_SUMMARY, args.timer_results (), [&](){
423+ fixture = test->create ();
424+ });
414425 fixture->processOptions (args);
415426 fixture->run (tests);
416427 }
0 commit comments