Skip to main content

test-runner.h File

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

Included Headers

#include <functional> #include <time.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

classtest_runner

The test runner for the µTest++ framework. 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
56#include <time.h>
57
58// ----------------------------------------------------------------------------
59
60#if defined(__GNUC__)
61#pragma GCC diagnostic push
62#pragma GCC diagnostic ignored "-Wpadded"
63#if defined(__clang__)
64#pragma clang diagnostic ignored "-Wc++98-compat"
65#endif
66#endif
67
69{
70 // --------------------------------------------------------------------------
71
72 // Forward definition.
73 class test_suite_base;
74
75 // --------------------------------------------------------------------------
76
99 {
100 public:
107 test_runner ();
108
112 test_runner (const test_runner&) = delete;
113
118
124 = delete;
125
131 = delete;
132
136 ~test_runner () = default;
137
148 void
149 initialize (int argc, char* argv[], const char* name);
150
158 int
159 exit_code (void);
160
168 void
170
171 size_t
173 {
174 return (test_suites != nullptr) ? test_suites->size () + 1 : 1;
175 }
176
185 constexpr const char*
186 name (void)
187 {
189 }
190
199 [[noreturn]] void
200 abort (void);
201
202 // ------------------------------------------------------------------------
203 public:
212 std::vector<test_suite_base*>* test_suites; // DO NOT INITIALISE!
213
214 struct
215 {
220
224 size_t failed_checks = 0;
225
229 size_t test_cases_count = 0;
231
232#if defined(_WIN32) || defined(CLOCK_MONOTONIC)
236 timespec begin_time{};
237
241 timespec end_time{};
242#endif
243
248
249 protected:
253 int argc_ = 0;
254
258 char** argv_ = nullptr;
259
263 const char* default_suite_name_ = "Test";
264 };
265
266 // --------------------------------------------------------------------------
267} // namespace micro_os_plus::micro_test_plus
268
269#if defined(__GNUC__)
270#pragma GCC diagnostic pop
271#endif
272
273// ----------------------------------------------------------------------------
274
275#endif // __cplusplus
276
277// ----------------------------------------------------------------------------
278
279#endif // MICRO_TEST_PLUS_TEST_RUNNER_H_
280
281// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.14.0.