micro-test-plus 6.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
reporter-tap.h
Go to the documentation of this file.
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
12// ----------------------------------------------------------------------------
13
30
31#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_REPORTER_TAP_H_
32#define MICRO_OS_PLUS_MICRO_TEST_PLUS_REPORTER_TAP_H_
33
34// ----------------------------------------------------------------------------
35
36#if defined(__cplusplus)
37
38// ----------------------------------------------------------------------------
39
40#if __has_include("micro-os-plus/project-config.h")
41#include "micro-os-plus/project-config.h"
42#endif // __has_include("micro-os-plus/project-config.h")
43
44#if __has_include("micro-os-plus/micro-test-plus-defines.h")
45#include "micro-os-plus/micro-test-plus-defines.h"
46#endif // __has_include("micro-os-plus/micro-test-plus-defines.h")
47
48#include "reporter.h"
49#include "reflection.h"
50
51// ----------------------------------------------------------------------------
52
53#if defined(__GNUC__)
54#pragma GCC diagnostic push
55
56#pragma GCC diagnostic ignored "-Wpadded"
57#if defined(__clang__)
58#pragma clang diagnostic ignored "-Wc++98-compat"
59#endif // defined(__clang__)
60#endif // defined(__GNUC__)
61
62// ============================================================================
63
65{
66 // ==========================================================================
67
90 class reporter_tap final : public reporter
91 {
92 public:
99 explicit reporter_tap (const runner_options& opts);
100
108 reporter_tap (const reporter_tap&) = delete;
109
118
128 = delete;
129
139 = delete;
140
147 ~reporter_tap () override;
148
149 // ------------------------------------------------------------------------
150
158 void
159 begin_session (const runner& runner) override;
160
168 void
169 end_session (const runner& runner) override;
170
178 void
179 begin_suite (const suite& suite) override;
180
188 void
189 end_suite (const suite& suite) override;
190
202 void
203 skip_suite (const suite& suite) override;
204
217 void
218 fail_suite (const std::string& message, const suite& suite) override;
219
227 void
228 begin_test_case (const test_case& test_case) override;
229
237 void
238 end_test_case (const test_case& test_case) override;
239
251 void
252 skip_test_case (const test_case& test_case) override;
253
267 void
268 pass_without_text (const test_case& test_case) override;
269
285 void
287 bool is_requirement) override;
288
297 const char*
298 comment_prefix (void) const noexcept override;
299
308 const char*
309 error_prefix (void) const noexcept override;
310
311 private:
320 void
321 output_pass_prefix (const std::string& message,
322 const test_case& test_case) override;
323
331 void
332 output_pass_suffix (const test_case& test_case) override;
333
345 void
346 output_fail_prefix (const std::string& message, const bool has_expression,
347 const reflection::source_location& location,
348 const test_case& test_case) override;
349
360 void
362 check_kind kind, const test_case& test_case) override;
363
377 void
378 commit_buffer (void) override;
379
396 void
397 display_open_heading (const open_test_case& open, bool is_first) override;
398
417 void
419
430
441 size_t condition_begin_ = std::string::npos;
442 };
443
444 // --------------------------------------------------------------------------
445} // namespace micro_os_plus::micro_test_plus::detail
446
447#if defined(__GNUC__)
448#pragma GCC diagnostic pop
449#endif // defined(__GNUC__)
450
451// ----------------------------------------------------------------------------
452
453#endif // defined(__cplusplus)
454
455// ----------------------------------------------------------------------------
456
457#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_REPORTER_TAP_H_
458
459// ----------------------------------------------------------------------------
void begin_test_case(const test_case &test_case) override
Marks the beginning of a test case.
reporter_tap(reporter_tap &&)=delete
Deleted move constructor to prevent moving.
void begin_suite(const suite &suite) override
Marks the beginning of a test suite.
void end_suite(const suite &suite) override
Marks the end of a test suite.
void fail_suite(const std::string &message, const suite &suite) override
Reports a failure of a test suite outside its test cases.
void skip_suite(const suite &suite) override
Reports a test suite skipped by the filter.
void skip_test_case(const test_case &test_case) override
Reports a test case skipped by the filter.
void output_pass_suffix(const test_case &test_case) override
Outputs the suffix for a passing condition.
void output_fail_prefix(const std::string &message, const bool has_expression, const reflection::source_location &location, const test_case &test_case) override
Outputs the prefix for a failing condition.
void display_open_heading(const open_test_case &open, bool is_first) override
Writes the # Subtest: heading of an open test case.
void pass_without_text(const test_case &test_case) override
Records a passed check whose text is not written.
void write_quiet_failures(void)
Writes the failed checks of the quiet verbosity, as comments.
void end_session(const runner &runner) override
Marks the end of a test session.
reporter_tap(const reporter_tap &)=delete
Deleted copy constructor to prevent copying.
reporter_tap(const runner_options &opts)
Constructor for the reporter_tap class.
const char * error_prefix(void) const noexcept override
Returns the TAP bail-out prefix string "Bail out! ".
void abort_session(const reflection::source_location &location, bool is_requirement) override
Reports the abort of the test execution.
void output_fail_suffix(const reflection::source_location &location, check_kind kind, const test_case &test_case) override
Outputs the suffix for a failing condition.
size_t description_begin_
The position in the buffer where the description of a passed check begins.
void output_pass_prefix(const std::string &message, const test_case &test_case) override
Outputs the prefix for a passing condition.
void begin_session(const runner &runner) override
Marks the beginning of a test session.
size_t condition_begin_
The position in the buffer where the expression of a failed check begins.
void end_test_case(const test_case &test_case) override
Marks the end of a test case.
void commit_buffer(void) override
Writes the results buffered for the outer test case before a nested test case begins.
const char * comment_prefix(void) const noexcept override
Returns the TAP comment prefix string "# ".
reporter_tap & operator=(const reporter_tap &)=delete
Deleted copy assignment operator to prevent copying.
friend class micro_test_plus::runner
The runner, which lists the test cases.
Definition reporter.h:301
reporter(const runner_options &opts)
Constructor for the reporter class.
Definition reporter.cpp:162
friend class micro_test_plus::test_case
The test case, which creates the checks.
Definition reporter.h:284
Local implementation of source location information for diagnostics.
Definition reflection.h:143
The configuration of a test session, and its command-line parser.
A named, runnable test suite registered with the test runner.
Definition test.h:2059
Internal implementation details for the µTest++ framework.
check_kind
The kind of a check, which determines what happens when it fails.
C++ header file with declarations for the µTest++ reflection utilities.
C++ header file with declarations for the µTest++ test reporter.
A test case that has begun and not yet ended.
Definition reporter.h:1325