37#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_RUNNER_H_
38#define MICRO_OS_PLUS_MICRO_TEST_PLUS_RUNNER_H_
42#if defined(__cplusplus)
46#if __has_include("micro-os-plus/project-config.h")
47#include "micro-os-plus/project-config.h"
50#if __has_include("micro-os-plus/micro-test-plus-defines.h")
51#include "micro-os-plus/micro-test-plus-defines.h"
71#pragma GCC diagnostic push
73#pragma GCC diagnostic ignored "-Wpadded"
75#pragma clang diagnostic ignored "-Wc++98-compat"
77#pragma GCC diagnostic ignored "-Wsuggest-final-types"
78#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
79#pragma GCC diagnostic ignored "-Wredundant-tags"
237#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
252 [[deprecated (
"use runner() and add_top_suite() (since 4.1.0)")]]
253 runner (
const char* top_suite_name);
309#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
341 [[deprecated (
"use initialise (argc, argv) and add_top_suite() "
342 "(since 6.0.0)")]]
class suite&
343 initialise (
int argc,
char* argv[],
const char* top_suite_name);
519#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
536 [[deprecated (
"use run_suites() (since 6.0.0)")]]
int
579 template <
typename Callable_T,
typename... Args_T>
583 Args_T&&... arguments);
585#if !defined(__DOXYGEN__)
604 template <
typename Callable_T,
typename... Args_T>
608 Args_T&&... arguments);
611#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
638 template <
typename Callable_T,
typename... Args_T>
639 [[deprecated (
"use add_suite() (since 6.0.0)")]]
void
640 suite (std::string_view
name, Callable_T&& callable,
641 Args_T&&... arguments);
781#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
798 [[deprecated (
"use verbosity_level() (since 6.0.0)"), nodiscard]]
auto
826#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
848 [[deprecated (
"the runner has no name; see add_top_suite() "
850 nodiscard]]
const char*
851 name (
void)
const noexcept;
869 "use added_suites_count() or total_suites_count() (since 6.0.0)"),
928 totals (
void)
const noexcept;
952 [[nodiscard]] std::span<const std::string>
955#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
976 [[deprecated (
"the timings are internal (since 6.0.0)"),
994 [[deprecated (
"the timings are internal (since 6.0.0)"),
1013 [[deprecated (
"use verbosity_level() (since 6.0.0)"),
1442#if defined(__GNUC__)
1443#pragma GCC diagnostic pop
Aggregated check and test case counters for a node in the test tree.
Human (standard output) implementation of reporter.
TAP (Test Anything Protocol) implementation of reporter.
Abstract base class for the reporters that display test results, including operand values for failure...
Non-template base for all runnable objects (suites and test cases).
Measures the elapsed time of an operation.
A name of a suite or of a test case, with the location where it was given.
Local implementation of source location information for diagnostics.
static constexpr source_location current(const char *file="unknown", unsigned int line={}) noexcept
Returns the current source location.
The configuration of a test session, and its command-line parser.
void reject_suite(const char *name, const reflection::source_location &location)
Rejects a suite constructed after run_suites() has started.
class suite * running_suite_
The suite whose body is running, if any.
counters totals_
Totals of the test session.
void run_child_suites(void)
Runs all registered test suites.
session_state
The states of a test session.
runner(runner &&)=delete
Deleted move constructor to prevent moving.
void list_test_case(const class suite &suite, const class test_case &test_case)
Lists a test case, instead of running it.
abort_handler_t abort_handler_
The function called by abort(), if not null.
bool has_option_errors(void) const noexcept
Checks whether an option error was found by initialise().
detail::stopwatch stopwatch_
Stopwatch of this runner.
static void link_static_suite(runner &test_runner, class suite &suite) noexcept
Inserts a static suite into the list of suites, or reject it.
int exit_code_
The exit code computed by run_suites().
void register_suite(std::unique_ptr< class suite > suite)
Registers a test suite with the runner.
auto verbosity_level(void) const noexcept -> micro_test_plus::verbosity
Returns the verbosity level of the console output.
void suite(std::string_view name, Callable_T &&callable, Args_T &&... arguments)
Deprecated name of add_suite().
runner * started_next_
The next runner in the list of the started runners.
bool is_selected(const char *name, size_t level) const
Checks whether a suite or a test case is selected by the filter pattern of its nesting level.
size_t skipped_suites_count(void) const noexcept
Returns the count of the test suites skipped by the filter.
const counters & totals(void) const noexcept
Returns the totals of the test session.
class suite & initialise(int argc, char *argv[], const char *top_suite_name)
Deprecated initialisation with the command-line arguments, which also adds the top suite.
bool has_top_suite_
Whether the top suite was added to the session.
runner & operator=(const runner &)=delete
Deleted copy assignment operator to prevent copying.
void mark_rejected(void) noexcept
Records that a call was rejected.
runner(void)
Constructor for the runner class.
const char * name(void) const noexcept
Deprecated name of the runner.
static runner * started_first_
The head of the list of the runners that have started.
detail::reporter & reporter(void) const noexcept
Deprecated access to the reporter of the test session.
std::unique_ptr< detail::reporter > reporter_
Owning pointer to the test reporter used for outputting test results.
size_t static_suites_count(void) const noexcept
Returns the count of static test suites.
void reject_call(const std::string &message, const reflection::source_location *location=nullptr)
Reports a rejected call, and records it.
size_t suites_count(void) const noexcept
Deprecated count of the test suites added with add_suite(), plus the top suite.
int run_suites(void)
Runs the registered suites, ends the session, and returns the exit code.
session_state session_state_
The current state of the test session.
abort_handler_t set_abort_handler(abort_handler_t handler) noexcept
Sets the function called when test execution is aborted.
class suite & add_top_suite(const located_name &top_suite_name)
Adds the top suite and returns it.
void abort(const reflection::source_location &sl=reflection::source_location::current())
Aborts test execution immediately.
std::span< const std::string > application_arguments(void) const noexcept
Returns the command-line arguments left to the application.
int exit_code(void)
Deprecated name of run_suites().
size_t listed_test_cases_count_
The number of listed test cases.
class top_suite top_suite_
The top suite, whose body is the code of main().
size_t added_suites_count(void) const noexcept
Returns the count of the test suites added with add_suite().
auto verbosity(void) const noexcept -> micro_test_plus::verbosity
Deprecated name of verbosity_level().
bool has_rejected_calls_
Whether a call was rejected.
void(*)(const reflection::source_location &sl) abort_handler_t
The type of the function called when test execution is aborted.
std::vector< std::unique_ptr< class suite > > children_suites_
Owning collection of dynamically registered child suites.
void add_suite(located_name name, Callable_T &&callable, Args_T &&... arguments)
Adds a test suite to the runner, to be run by run_suites().
size_t total_suites_count(void) const noexcept
Returns the count of all the test suites.
size_t listed_suites_count_
The number of suites with listed test cases.
runner_options options_
The options of the test session.
test_case * running_test_case_
The innermost test case being run, if any.
bool aborted_
Whether the test execution was aborted.
runner(const runner &)=delete
Deleted copy constructor to prevent copying.
bool is_listing(void) const noexcept
Checks whether the test cases are listed instead of run.
size_t skipped_suites_count_
The number of suites skipped by the filter.
friend class static_suite
The static suites link themselves through the runner.
const detail::stopwatch & timings(void) const noexcept
Deprecated access to the timings of the test session.
const class suite * listed_suite_
The suite whose name was listed last, if any.
A named, runnable test suite registered with the test runner.
suite(located_name &&name, runner &test_runner, Callable_T &&callable, Args_T &&... arguments)
Constructs a suite with a name, runner, and callable body.
A named, runnable test case that lives inside a suite.
The optional top suite owned by every runner instance.
Concept satisfied by a callable object that can be the body of a suite.
C++ header file with declarations for the µTest++ counters.
verbosity
The verbosity levels for test reporting.
Primary namespace for the µTest++ testing framework.
C++ header file with declarations for the µTest++ reflection utilities.
C++ header file with declarations for the µTest++ test reporter.
C++ header file with inline implementations for the µTest++ test runner.
C++ header file with declarations for the µTest++ runner options.
C++ header file with declarations for the µTest++ stopwatch.
C++ header file with declarations for the µTest++ test hierarchy.