Skip to main content

runner.h File

C++ header file with declarations for the µTest++ test runner. More...

Included Headers

#include <functional> #include <memory> #include <string> #include "timings.h" #include "test.h" #include "reflection.h" #include "inlines/runner-inlines.h"

Namespaces Index

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespacemicro_test_plus

Primary namespace for the µTest++ testing framework. More...

Classes Index

classrunner

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

classstatic_runner

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

Description

C++ header file with declarations for the µTest++ test runner.

This header provides the declarations for the test runner facilities used within the µTest++ framework. It defines the interface for managing the registration and execution of test suites, supporting automated discovery and orchestration of tests across a project.

The test runner is responsible for initialising the test environment, registering test suites, managing command-line arguments, and determining the overall test result via an exit code. It also provides mechanisms for aborting test execution and retrieving the default suite name.

All definitions reside within the micro_os_plus::micro_test_plus namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.

The header files are organised within the include/micro-os-plus/micro-test-plus folder to maintain a structured and modular codebase.

This file is intended solely for internal use within the framework and should not be included directly by user code.

File Listing

The file content with the documentation metadata removed is:

1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can be
9 * obtained from https://opensource.org/licenses/mit.
10 *
11 * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12 * released under the terms of the Boost Version 1 Software License,
13 * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14 */
15
16// ----------------------------------------------------------------------------
17
44
45#ifndef MICRO_TEST_PLUS_TEST_RUNNER_H_
46#define MICRO_TEST_PLUS_TEST_RUNNER_H_
47
48// ----------------------------------------------------------------------------
49
50#ifdef __cplusplus
51
52// ----------------------------------------------------------------------------
53
54#include <functional>
55#include <memory>
56#include <string>
57
58#include "timings.h"
59#include "test.h"
60#include "reflection.h"
61
62// ----------------------------------------------------------------------------
63
64#if defined(__GNUC__)
65#pragma GCC diagnostic push
66#pragma GCC diagnostic ignored "-Wpadded"
67#if defined(__clang__)
68#pragma clang diagnostic ignored "-Wc++98-compat"
69#else // GCC only
70#pragma GCC diagnostic ignored "-Wsuggest-final-types"
71#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
72#pragma GCC diagnostic ignored "-Wredundant-tags"
73#endif
74#endif
75
76// ============================================================================
77
79{
80 // --------------------------------------------------------------------------
81
82 class suite;
83 class top_suite;
84 class reporter;
85
86 // ==========================================================================
87
111 {
112 public:
119 runner (void);
120
129 runner (const char* top_suite_name);
130
134 runner (const runner&) = delete;
135
139 runner (runner&&) = delete;
140
144 runner&
146 = delete;
147
151 runner&
153 = delete;
154
158 virtual ~runner () override;
159
169 class suite&
170 initialise (int argc, char* argv[], const char* top_suite_name = "");
171
179 int
180 exit_code (void);
181
196 template <typename Callable_T, typename... Args_T>
197 void
198 suite (const char* name, Callable_T&& callable, Args_T&&... arguments);
199
200 // ------------------------------------------------------------------------
201
209 [[noreturn]] void
212
213 // ------------------------------------------------------------------------
214 // Getters.
215
223 [[nodiscard]] virtual size_t
224 total_suites_count (void) const noexcept;
225
233 [[nodiscard]] class reporter&
234 reporter (void) const noexcept;
235
243 [[nodiscard]] detail::timestamps&
244 timings () noexcept;
245
253 [[nodiscard]] const detail::timestamps&
254 timings () const noexcept;
255
263 [[nodiscard]] size_t
264 suites_count (void) const noexcept;
265
266 protected:
273 virtual void
274 run_suites_ (void);
275
283 void
284 register_suite_ (std::unique_ptr<class suite> suite);
285
286 // ------------------------------------------------------------------------
287 protected:
292
301 std::vector<std::unique_ptr<class suite>> children_suites_;
302
306 std::unique_ptr<class reporter> reporter_;
307
311 detail::timestamps timings_;
312
316 std::string top_suite_name_;
317 };
318
319 // ==========================================================================
320
344 class static_runner final : public runner
345 {
346 public:
353 static_runner (void);
354
363 static_runner (const char* top_suite_name);
364
368 static_runner (const static_runner&) = delete;
369
374
380 = delete;
381
387 = delete;
388
392 virtual ~static_runner () override;
393
394 // ------------------------------------------------------------------------
395
402 static void
404
412 [[nodiscard]] size_t
413 static_suites_count (void) const noexcept;
414
423 [[nodiscard]] virtual size_t
424 total_suites_count (void) const noexcept final override;
425
426 protected:
433 void
434 run_suites_ (void) override;
435
436 protected:
450 std::vector<static_suite*>* static_children_suites_;
451 };
452
453} // namespace micro_os_plus::micro_test_plus
454
455#if defined(__GNUC__)
456#pragma GCC diagnostic pop
457#endif
458
459// ----------------------------------------------------------------------------
460
461#endif // __cplusplus
462
463// ============================================================================
464// Templates & constexpr implementations.
465
467
468// ----------------------------------------------------------------------------
469
470#endif // MICRO_TEST_PLUS_TEST_RUNNER_H_
471
472// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.