Skip to main content

static_runner Class

A runner variant that also manages statically-registered test suites. More...

Declaration

class micro_os_plus::micro_test_plus::static_runner { ... }

Included Headers

Base class

classrunner

The test runner for the µTest++ framework. More...

Public Constructors Index

static_runner (const char *top_suite_name)

Constructs the static runner with a top-suite name. More...

static_runner (const static_runner &)=delete

Deleted copy constructor to prevent copying. More...

static_runner (static_runner &&)=delete

Deleted move constructor to prevent moving. More...

static_runner (void)

Constructor for the runner class. More...

Public Destructor Index

~static_runner () override

Destructor for the static_runner class. More...

Public Operators Index

static_runner &operator= (const static_runner &)=delete

Deleted copy assignment operator to prevent copying. More...

static_runner &operator= (static_runner &&)=delete

Deleted move assignment operator to prevent moving. More...

Public Member Functions Index

voidabort (const reflection::source_location &sl=reflection::source_location::current())

Aborts test execution immediately. More...

intexit_code (void)

Returns 0 if all tests were successful, 1 otherwise. More...

class suite &initialise (int argc, char *argv[], const char *top_suite_name="")

Initialises the test runner with command-line arguments. More...

const char *name (void) const noexcept

Gets the node name. More...

class reporter &reporter (void) const noexcept

Returns a reference to the test reporter. More...

size_tstatic_suites_count (void) const noexcept

Returns the total count of registered static test suites. More...

template <typename Callable_T, typename... Args_T>
voidsuite (const char *name, Callable_T &&callable, Args_T &&... arguments)

Adds a test suite to the runner. More...

size_tsuites_count (void) const noexcept

Returns the count of test suites. More...

const detail::timestamps &timings () const noexcept

Gets the timings for this runner (const overload). More...

detail::timestamps &timings () noexcept

Gets the timings for this runner. More...

size_ttotal_suites_count (void) const noexcept final override

Returns the total count of all test suites, including static and dynamic. More...

const runner_totals &totals () const noexcept

Gets the totals for the test (const overload). More...

runner_totals &totals () noexcept

Gets the totals for the test. More...

Protected Member Functions Index

voidregister_suite_ (std::unique_ptr< class suite > suite)

Registers a test suite with the runner. More...

voidrun_suites_ (void) override

Runs all child suites, including statically registered ones. More...

Protected Member Attributes Index

std::vector< std::unique_ptr< class suite > >children_suites_

Owning collection of dynamically registered child suites. More...

const char *name_

The test node name. More...

std::unique_ptr< class reporter >reporter_

Pointer to the test reporter used for outputting test results. More...

std::vector< static_suite * > *static_children_suites_

Pointer to the vector of registered static test suites. More...

detail::timestampstimings_

Timings for this runner. More...

class { ... }top_suite_

The implicit top-level suite; always present and executed first. More...

std::stringtop_suite_name_

Owned storage for the implicit top-suite name. More...

runner_totalstotals_

Totals for the test node, including nested cases. More...

Public Static Functions Index

static voidregister_static_suite (static_runner &runner, static_suite &suite)

Registers a static test suite with the runner. More...

Description

A runner variant that also manages statically-registered test suites.

static_runner extends runner to handle static_suite objects that are declared at namespace scope and therefore constructed before or after the runner itself, in unspecified static-initialisation order.

The key design constraint is that static_runner instances must themselves be declared at namespace scope (in the BSS segment), so the pointer static_children_suites_ is zero-initialised by the C runtime before any constructor runs. This ensures that static_suite objects constructed before static_runner can safely append themselves to the vector without losing registrations.

During exit_code(), run_suites_() is called, which first runs all dynamically registered suites (base class behaviour) and then iterates over the statically registered suites.

Definition at line 377 of file runner.h.

Public Constructors

static_runner()

micro_os_plus::micro_test_plus::static_runner::static_runner (const char * top_suite_name)

Constructs the static runner with a top-suite name.

Parameters
top_suite_name

The name of the implicit top-level suite. Defaults to an empty string.

Deprecated

Use the anonymous constructor.

Delegates construction to the runner base class with the given top_suite_name. If tracing is enabled, the function signature and suite name are output for diagnostic purposes.

Declaration at line 396 of file runner.h, definition at line 449 of file runner.cpp.

449 static_runner::static_runner (const char* top_suite_name)
450 : runner{ top_suite_name }
451 {
452#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
453 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name ());
454#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED
455 }

References micro_os_plus::micro_test_plus::runner::runner and micro_os_plus::micro_test_plus::detail::test_node::name.

static_runner()

micro_os_plus::micro_test_plus::static_runner::static_runner (const static_runner &)
delete

Deleted copy constructor to prevent copying.

Definition at line 401 of file runner.h.

Reference static_runner.

static_runner()

micro_os_plus::micro_test_plus::static_runner::static_runner (static_runner &&)
delete

Deleted move constructor to prevent moving.

Definition at line 406 of file runner.h.

Reference static_runner.

static_runner()

micro_os_plus::micro_test_plus::static_runner::static_runner (void)

Constructor for the runner class.

Parameters

None.

Delegates construction to the runner base class. If tracing is enabled, the function signature and suite name are output for diagnostic purposes.

Declaration at line 386 of file runner.h, definition at line 436 of file runner.cpp.

437 {
438#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
439 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name ());
440#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED
441 }

References micro_os_plus::micro_test_plus::runner::runner and micro_os_plus::micro_test_plus::detail::test_node::name.

Referenced by static_runner, static_runner, operator=, operator= and register_static_suite.

Public Destructor

~static_runner()

micro_os_plus::micro_test_plus::static_runner::~static_runner ()
virtual

Destructor for the static_runner class.

If static_children_suites_ is non-null, the dynamically allocated vector of raw pointers is deleted and the pointer is reset to nullptr. The pointed-to static_suite objects are not deleted, as they are static storage-duration objects. If tracing is enabled, the function signature is output for diagnostic purposes.

Declaration at line 425 of file runner.h, definition at line 465 of file runner.cpp.

466 {
467#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
468 trace::printf ("%s\n", __PRETTY_FUNCTION__);
469#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED
470
471 if (static_children_suites_ != nullptr)
472 {
473 // The tests are static, so we do not delete them, but we need to
474 // delete the array of pointers.
477 }
478 }

Reference static_children_suites_.

Public Operators

operator=()

static_runner & micro_os_plus::micro_test_plus::static_runner::operator= (const static_runner &)
delete

Deleted copy assignment operator to prevent copying.

Definition at line 412 of file runner.h.

Reference static_runner.

operator=()

static_runner & micro_os_plus::micro_test_plus::static_runner::operator= (static_runner &&)
delete

Deleted move assignment operator to prevent moving.

Definition at line 419 of file runner.h.

References micro_os_plus::micro_test_plus::runner::runner, static_runner, register_static_suite, static_suites_count and micro_os_plus::micro_test_plus::runner::suite.

Public Member Functions

abort()

void micro_os_plus::micro_test_plus::runner::abort (const reflection::source_location & sl=reflection::source_location::current())

Aborts test execution immediately.

Parameters
sl

The source location from which the abort is triggered.

Returns

Nothing.

Prints the source location of the fatal error to stderr and then terminates the process via ::abort().

Declaration at line 243 of file runner.h, definition at line 394 of file runner.cpp.

395 {
396#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
397 trace::printf ("%s\n", __PRETTY_FUNCTION__);
398#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
399
400 fprintf (stderr, "\nerror: test execution aborted at %s:%u\n",
402
403 ::abort ();
404 }

References micro_os_plus::micro_test_plus::runner::abort, micro_os_plus::micro_test_plus::reflection::source_location::file_name, micro_os_plus::micro_test_plus::reflection::source_location::line and micro_os_plus::micro_test_plus::reflection::short_name.

Referenced by micro_os_plus::micro_test_plus::runner::abort.

exit_code()

int micro_os_plus::micro_test_plus::runner::exit_code (void)

Returns 0 if all tests were successful, 1 otherwise.

Parameters

None.

Returns

Integer exit code representing the overall test result.

Finalises the top suite by recording its end timestamp and notifying the reporter, then accumulates its totals into the runner totals. Subsequently invokes run_suites_() to sort, execute, and accumulate all registered child suites. Finally, records the session end timestamp, notifies the reporter, and returns 0 if all checks passed or 1 otherwise.

Declaration at line 213 of file runner.h, definition at line 358 of file runner.cpp.

359 {
360#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
361 trace::printf ("%s\n", __PRETTY_FUNCTION__);
362#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
363
364 if (reporter_ == nullptr)
365 {
366 fprintf (stderr, "error: test runner not initialised\n");
367 return 1;
368 }
369
370 top_suite_.timings ().timestamp_end ();
371 reporter_->end_suite (top_suite_);
372 totals_ += top_suite_.totals ();
373
374 run_suites_ ();
375
376 timings_.timestamp_end ();
377 reporter_->end_session (*this);
378
379 const int result = totals_.was_successful () ? 0 : 1;
380
381#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
382 trace::printf ("%s -> %d\n", __PRETTY_FUNCTION__, result);
383#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
384
385 return result;
386 }

References micro_os_plus::micro_test_plus::runner::reporter_, micro_os_plus::micro_test_plus::runner::run_suites_, micro_os_plus::micro_test_plus::runner::timings_, micro_os_plus::micro_test_plus::runner::top_suite_ and micro_os_plus::micro_test_plus::detail::test_node::totals_.

initialise()

suite & micro_os_plus::micro_test_plus::runner::initialise (int argc, char * argv=[], const char * top_suite_name="")

Initialises the test runner with command-line arguments.

Parameters
argc

The argument count from main().

argv

The argument vector from main().

top_suite_name

The name given to the implicit top suite. Defaults to an empty string.

Returns

Reference to the top-level test suite.

Captures command-line arguments, selects the reporter implementation (human or tap), starts session timing, and emits the initial reporter notifications for the session and top suite.

If the top suite name is not provided, it attempts to derive a name from argv[0] or defaults to "default suite".

If tracing is enabled, the command-line arguments are also logged for diagnostic purposes.

Declaration at line 203 of file runner.h, definition at line 165 of file runner.cpp.

165 runner::initialise (int argc, char* argv[], const char* top_suite_name)
166 {
167#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
168 trace::printf ("%s\n", __PRETTY_FUNCTION__);
169
170#if !(defined(MICRO_OS_PLUS_STARTUP_ENABLED) \
171 && defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED))
172#if defined(MICRO_OS_PLUS_DEBUG_ENABLED)
173 trace::printf ("argv[");
174 for (int i = 0; i < argc; ++i)
175 {
176 if (i > 0)
177 {
178 trace::printf (", ");
179 }
180 trace::printf ("'%s'", argv[i]);
181 }
182 trace::puts ("]");
183#endif // defined(MICRO_OS_PLUS_DEBUG_ENABLED)
184#endif // !defined(MICRO_OS_PLUS_STARTUP_ENABLED)
185#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
186
187 if (strlen (top_suite_name) > 0)
188 {
189 // If provided by this call, use it, possibly override the
190 // deprecated constructor.
191 top_suite_name_ = top_suite_name;
192 top_suite_.name (top_suite_name_.c_str ());
193 }
194 else if (strlen (top_suite_.name ()) == 0)
195 {
196 // If not provided by the constructor or by this call, try to extract a
197 // name from argv[0], which is commonly the executable name. If that
198 // fails, use a default name.
199 if (argc > 0 && argv != nullptr && argv[0] != nullptr)
200 {
201 std::string_view top_suite_name_view{ utility::extract_file_name (
202 argv[0]) };
203
204 const auto dot_pos = top_suite_name_view.rfind ('.');
205 if (dot_pos != std::string_view::npos)
206 {
207 top_suite_name_view = top_suite_name_view.substr (0, dot_pos);
208 }
209
210 top_suite_name_ = top_suite_name_view;
211 }
212 else
213 {
214 top_suite_name_ = "default suite";
215 }
216 top_suite_.name (top_suite_name_.c_str ());
217 }
218
219 std::vector<std::string_view> argvs (argv, argv + argc);
220
221 std::string_view reporter_name{ "tap" };
222 static constexpr std::string_view reporter_prefix{ "--reporter=" };
223 for (size_t i = 0; i < argvs.size (); ++i)
224 {
225 if (argvs[i].starts_with (reporter_prefix))
226 {
227 reporter_name = argvs[i].substr (reporter_prefix.size ());
228 }
229 else if (argvs[i]
230 == reporter_prefix.substr (0, reporter_prefix.size () - 1))
231 {
232 if (i + 1 < argvs.size ())
233 {
234 reporter_name = argvs[++i];
235 }
236 else
237 {
238 fprintf (stderr, "error: --reporter option requires a "
239 "reporter name argument\n");
240 exit (1);
241 }
242 }
243 }
244
245 // Initialise and configure the reporter.
246 if (reporter_name == "human")
247 {
248 reporter_ = std::make_unique<reporter_human> (
249 std::make_unique<std::vector<std::string_view>> (
250 std::move (argvs)));
251 }
252 else if (reporter_name == "tap")
253 {
254 reporter_ = std::make_unique<reporter_tap> (
255 std::make_unique<std::vector<std::string_view>> (
256 std::move (argvs)));
257 }
258 else
259 {
260 fprintf (stderr, "error: unknown reporter '%.*s'\n",
261 static_cast<int> (reporter_name.size ()),
262 reporter_name.data ());
263 exit (1);
264 }
265
266 // ------------------------------------------------------------------------
267
268 timings_.timestamp_begin ();
269 reporter_->begin_session (*this);
270
271 top_suite_.timings ().timestamp_begin ();
272 reporter_->begin_suite (top_suite_);
273
274 return top_suite_;
275 }

References micro_os_plus::micro_test_plus::utility::extract_file_name, micro_os_plus::micro_test_plus::runner::reporter_, micro_os_plus::micro_test_plus::runner::timings_, micro_os_plus::micro_test_plus::runner::top_suite_ and micro_os_plus::micro_test_plus::runner::top_suite_name_.

name()

reporter()

class reporter & micro_os_plus::micro_test_plus::runner::reporter (void)
inline nodiscard noexcept

Returns a reference to the test reporter.

Parameters

None.

Returns

Reference to the test reporter.

Returns a reference to the reporter object stored in the unique pointer.

Declaration at line 267 of file runner.h, definition at line 79 of file runner-inlines.h.

79 runner::reporter (void) const noexcept
80 {
81 return *reporter_;
82 }

Reference micro_os_plus::micro_test_plus::runner::reporter_.

Referenced by micro_os_plus::micro_test_plus::runner::operator=.

static_suites_count()

size_t micro_os_plus::micro_test_plus::static_runner::static_suites_count (void)
nodiscard noexcept

Returns the total count of registered static test suites.

Parameters

None.

Returns

The total number of registered static test suites.

Returns the number of elements in static_children_suites_, or zero if the vector has not been allocated yet.

Declaration at line 446 of file runner.h, definition at line 486 of file runner.cpp.

487 {
488 return static_children_suites_ != nullptr
490 : 0;
491 }

Reference static_children_suites_.

Referenced by operator= and total_suites_count.

suite()

template <typename Callable_T, typename... Args_T>
void micro_os_plus::micro_test_plus::runner::suite (const char * name, Callable_T && callable, Args_T &&... arguments)

Adds a test suite to the runner.

Template Parameters
Callable_T

The type of a callable object.

Args_T

The types of the callable arguments.

Parameters
name

The test suite name or description, used in reports.

callable

A generic callable object, usually a lambda, invoked to perform the test suite.

arguments

A possibly empty list of arguments to be passed to the callable.

Returns

Nothing.

Constructs a suite object on the heap, binding the callable and any additional arguments, then transfers ownership to the runner via register_suite_(). The suite runs immediately as part of the registration process.

Declaration at line 231 of file runner.h, definition at line 115 of file runner-inlines.h.

115 runner::suite (const char* name, Callable_T&& callable,
116 Args_T&&... arguments)
117 {
118#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
119 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name);
120#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
121
122 auto child_suite = std::make_unique<class suite> (
123 name, *this, std::forward<Callable_T> (callable),
124 std::forward<Args_T> (arguments)...);
125
126 register_suite_ (std::move (child_suite));
127 }

References micro_os_plus::micro_test_plus::detail::test_node::name and micro_os_plus::micro_test_plus::runner::register_suite_.

Referenced by micro_os_plus::micro_test_plus::runner::operator=, operator=, register_static_suite and micro_os_plus::micro_test_plus::runner::register_suite_.

suites_count()

size_t micro_os_plus::micro_test_plus::runner::suites_count (void)
nodiscard noexcept

Returns the count of test suites.

Parameters

None.

Returns

The number of test suites, including the top one.

Returns the number of registered child suites plus one, accounting for the top suite.

Declaration at line 297 of file runner.h, definition at line 412 of file runner.cpp.

412 runner::suites_count (void) const noexcept
413 {
414 return children_suites_.size () + 1;
415 }

Reference micro_os_plus::micro_test_plus::runner::children_suites_.

Referenced by micro_os_plus::micro_test_plus::runner::operator=, run_suites_, micro_os_plus::micro_test_plus::runner::total_suites_count and total_suites_count.

timings()

const detail::timestamps & micro_os_plus::micro_test_plus::runner::timings ()
inline nodiscard noexcept

Gets the timings for this runner (const overload).

Parameters

None.

Returns

A const reference to the timestamps instance.

Returns a const reference to the timestamps member.

Declaration at line 287 of file runner.h, definition at line 99 of file runner-inlines.h.

99 runner::timings () const noexcept
100 {
101 return timings_;
102 }

Reference micro_os_plus::micro_test_plus::runner::timings_.

timings()

detail::timestamps & micro_os_plus::micro_test_plus::runner::timings ()
inline nodiscard noexcept

Gets the timings for this runner.

Parameters

None.

Returns

A reference to the timestamps instance.

Returns a reference to the timestamps member.

Declaration at line 277 of file runner.h, definition at line 89 of file runner-inlines.h.

89 runner::timings () noexcept
90 {
91 return timings_;
92 }

Reference micro_os_plus::micro_test_plus::runner::timings_.

Referenced by micro_os_plus::micro_test_plus::reporter_human::end_session, micro_os_plus::micro_test_plus::reporter_tap::end_session and micro_os_plus::micro_test_plus::runner::operator=.

total_suites_count()

size_t micro_os_plus::micro_test_plus::static_runner::total_suites_count (void)
nodiscard noexcept virtual

Returns the total count of all test suites, including static and dynamic.

Parameters

None.

Returns

The total number of test suites.

Returns the combined count of dynamically registered suites (from the base runner) and statically registered suites.

Declaration at line 457 of file runner.h, definition at line 499 of file runner.cpp.

500 {
501 return suites_count () + static_suites_count ();
502 }

References static_suites_count and micro_os_plus::micro_test_plus::runner::suites_count.

totals()

const runner_totals & micro_os_plus::micro_test_plus::detail::test_node::totals ()
inline nodiscard noexcept

Gets the totals for the test (const overload).

Parameters

None.

Returns

A const reference to the runner_totals instance.

Returns a const reference to the runner_totals member.

Declaration at line 224 of file test.h, definition at line 114 of file test-inlines.h.

114 test_node::totals () const noexcept
115 {
116 return totals_;
117 }

Reference micro_os_plus::micro_test_plus::detail::test_node::totals_.

totals()

Protected Member Functions

register_suite_()

void micro_os_plus::micro_test_plus::runner::register_suite_ (std::unique_ptr< class suite > suite)
protected

Registers a test suite with the runner.

Parameters
suite

Owning pointer to the test suite to register.

Returns

Nothing.

Takes ownership of the supplied suite unique pointer and appends it to the internal children_suites_ vector, deferring execution until run_suites_() is called. If tracing is enabled, the suite name is logged for diagnostic purposes.

Declaration at line 317 of file runner.h, definition at line 291 of file runner.cpp.

291 runner::register_suite_ (std::unique_ptr<class suite> suite)
292 {
293#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
294 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, suite->name ());
295#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
296
297 children_suites_.push_back (std::move (suite));
298 }

References micro_os_plus::micro_test_plus::runner::children_suites_ and micro_os_plus::micro_test_plus::runner::suite.

Referenced by micro_os_plus::micro_test_plus::runner::operator= and micro_os_plus::micro_test_plus::runner::suite.

run_suites_()

void micro_os_plus::micro_test_plus::static_runner::run_suites_ (void)
protected virtual

Runs all child suites, including statically registered ones.

Parameters

None.

First invokes runner::run_suites_() to execute all dynamically registered child suites. If static_children_suites_ is non-null, its contents are sorted alphabetically by suite name using selection sort on raw pointers, each suite is assigned a 1-based index offset by the dynamic suite count, executed via suite::run(), and its totals are accumulated into the runner totals.

Declaration at line 467 of file runner.h, definition at line 514 of file runner.cpp.

515 {
516#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
517 trace::printf ("%s\n", __PRETTY_FUNCTION__);
518#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
519
521
522 if (static_children_suites_ != nullptr)
523 {
524 // Use selection sort with std::swap on raw pointers (returns void)
525 // to avoid std::sort triggering -Waggregate-return via
526 // std::move_backward returning a class-type iterator.
527 const size_t n = static_children_suites_->size ();
528 auto& suites = *static_children_suites_;
529 for (size_t i = 0; i < n; ++i)
530 {
531 size_t min_idx = i;
532 for (size_t j = i + 1; j < n; ++j)
533 {
534 if (std::string_view{ suites[j]->name () }
535 < std::string_view{ suites[min_idx]->name () })
536 min_idx = j;
537 }
538 if (min_idx != i)
539 std::swap (suites[i], suites[min_idx]);
540 }
541
542 for (size_t i = 0; i < n; ++i)
543 {
544 auto* suite_ptr = suites[i];
545
546 suite_ptr->own_index (i + 1 + suites_count ());
547
548 // Run the child suite immediately.
549 suite_ptr->run ();
550
551 // Accumulate the totals from the static suite into the runner
552 // totals.
553 // DO NOT increment executed_subtests here.
554 totals_ += suite_ptr->totals ();
555 }
556 }
557 }

References micro_os_plus::micro_test_plus::runner::run_suites_, static_children_suites_, micro_os_plus::micro_test_plus::runner::suites_count and micro_os_plus::micro_test_plus::detail::test_node::totals_.

Protected Member Attributes

children_suites_

std::vector<std::unique_ptr<class suite> > micro_os_plus::micro_test_plus::runner::children_suites_
protected

Owning collection of dynamically registered child suites.

Each call to runner::suite() appends a new suite to this vector and runs it immediately. The vector retains ownership of all suites for the lifetime of the runner.

Definition at line 334 of file runner.h.

334 std::vector<std::unique_ptr<class suite>> children_suites_;

Referenced by micro_os_plus::micro_test_plus::runner::register_suite_, micro_os_plus::micro_test_plus::runner::run_suites_ and micro_os_plus::micro_test_plus::runner::suites_count.

name_

const char* micro_os_plus::micro_test_plus::detail::test_node::name_
protected

reporter_

std::unique_ptr<class reporter> micro_os_plus::micro_test_plus::runner::reporter_
protected

Pointer to the test reporter used for outputting test results.

Definition at line 339 of file runner.h.

339 std::unique_ptr<class reporter> reporter_;

Referenced by micro_os_plus::micro_test_plus::runner::exit_code, micro_os_plus::micro_test_plus::runner::initialise and micro_os_plus::micro_test_plus::runner::reporter.

static_children_suites_

std::vector<static_suite*>* micro_os_plus::micro_test_plus::static_runner::static_children_suites_
protected

Pointer to the vector of registered static test suites.

static_runner instances are always declared at namespace scope, so this pointer lives in the BSS segment and is zero-initialised before any constructor runs. This guarantees that static test suites registered before this runner's constructor executes (due to unspecified static initialisation order across translation units) are not lost. The pointer MUST NOT carry an explicit default member initialiser, as that would run during construction and could overwrite a value already set by an earlier-constructed static_suite.

Definition at line 483 of file runner.h.

483 std::vector<static_suite*>* static_children_suites_;

Referenced by ~static_runner, run_suites_ and static_suites_count.

timings_

detail::timestamps micro_os_plus::micro_test_plus::runner::timings_
protected

top_suite_

class top_suite micro_os_plus::micro_test_plus::runner::top_suite_
protected

top_suite_name_

std::string micro_os_plus::micro_test_plus::runner::top_suite_name_
protected

Owned storage for the implicit top-suite name.

Definition at line 349 of file runner.h.

349 std::string top_suite_name_;

Referenced by micro_os_plus::micro_test_plus::runner::initialise.

totals_

runner_totals micro_os_plus::micro_test_plus::detail::test_node::totals_
protected

Public Static Functions

register_static_suite()

void micro_os_plus::micro_test_plus::static_runner::register_static_suite (static_runner & runner, static_suite & suite)
static

Registers a static test suite with the runner.

Parameters
runner

The static runner instance.

suite

The static test suite to register.

If runner.static_children_suites_ is null, a new std::vector<static_suite*> is heap-allocated and assigned to it. The address of suite is then appended to the vector. This method is intended to be called from the constructor of static_suite, before test execution begins.

Declaration at line 436 of file runner.h, definition at line 568 of file runner.cpp.

570 {
571#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
572 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, suite.name ());
573#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
574
575 if (runner.static_children_suites_ == nullptr)
576 {
577#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
578 trace::printf ("%s new static_children_suites_ array\n",
579 __PRETTY_FUNCTION__);
580#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
581 runner.static_children_suites_ = new std::vector<static_suite*>;
582 }
583 runner.static_children_suites_->push_back (&suite);
584 }

References micro_os_plus::micro_test_plus::runner::runner, static_runner and micro_os_plus::micro_test_plus::runner::suite.

Referenced by operator= and micro_os_plus::micro_test_plus::detail::register_static_suite.


The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.17.0.