micro-test-plus 3.2.2
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::test_suite_base Class Reference

Base class for all test suites. More...

#include <micro-os-plus/micro-test-plus.h>

Inheritance diagram for micro_os_plus::micro_test_plus::test_suite_base:

Public Member Functions

 test_suite_base (const char *name)
 Constructs a test suite.
 test_suite_base (const test_suite_base &)=delete
 Deleted copy constructor to prevent copying.
 test_suite_base (test_suite_base &&)=delete
 Deleted move constructor to prevent moving.
virtual ~test_suite_base ()
 Virtual destructor for the test_suite_base class.
void begin_test_case (const char *name)
 Marks the beginning of a named test case.
void begin_test_suite (void)
 Begins the execution of the test suite.
void end_test_case (void)
 Marks the end of a test case.
void end_test_suite (void)
 Marks the end of the test suite.
constexpr int failed_checks (void)
 Gets the number of test conditions that failed.
void increment_failed (void)
 Increments the count of failed test conditions.
void increment_successful (void)
 Increments the count of passed test conditions.
constexpr const char * name (void)
 Gets the suite name.
test_suite_baseoperator= (const test_suite_base &)=delete
 Deleted copy assignment operator to prevent copying.
test_suite_baseoperator= (test_suite_base &&)=delete
 Deleted move assignment operator to prevent moving.
virtual void run (void)
 Runs the sequence of test cases in the suite.
constexpr int successful_checks (void)
 Gets the number of conditions that passed.
constexpr int test_cases (void)
 Gets the number of test cases.
constexpr bool unused (void)
 Checks if the test suite was not used.
constexpr bool was_successful (void)
 Gets the test suite result.

Public Attributes

struct { 
   int   failed_checks 
 Number of failed checks in the current test case. More...
   int   successful_checks 
 Number of successful checks in the current test case. More...
current_test_case
 Structure holding the current test case's check counters.
bool process_deferred_begin = true
 Indicates whether to process deferred begin for test cases.

Protected Attributes

int failed_checks_ = 0
 Count of test conditions that failed.
const char * name_
 The test suite name.
int successful_checks_ = 0
 Count of test conditions that passed.
const char * test_case_name_
 The current test case name.
int test_cases_ = 0
 Count of test cases in the test suite.

Detailed Description

The test_suite_base class provides the foundational interface for managing test suites within the µTest++ framework. It maintains counters for successful and failed checks, tracks test cases, and offers methods for marking the commencement and completion of test cases and suites.

This class ensures consistent state management and reporting for all derived test suites. It also provides utility methods for querying the suite's name, the number of successful and failed checks, the number of test cases, and the overall result of the suite.

All members and methods are defined within the micro_os_plus::micro_test_plus namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.

Definition at line 97 of file test-suite.h.

Constructor & Destructor Documentation

◆ test_suite_base() [1/3]

micro_os_plus::micro_test_plus::test_suite_base::test_suite_base ( const char * name)
Parameters
[in]nameThe test suite name.

The rule of five is enforced to prevent accidental copying or moving.

The constructor initialises a new instance of the test_suite_base class with the specified name. It sets up the internal state required for managing test cases within the suite. If tracing is enabled, the function signature is output for diagnostic purposes. The default test suite does not require explicit registration, ensuring seamless integration within the µTest++ framework and supporting organised test management across all files and folders.

Definition at line 75 of file test-suite.cpp.

◆ test_suite_base() [2/3]

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

◆ test_suite_base() [3/3]

micro_os_plus::micro_test_plus::test_suite_base::test_suite_base ( test_suite_base && )
delete

◆ ~test_suite_base()

micro_os_plus::micro_test_plus::test_suite_base::~test_suite_base ( )
virtual

The destructor releases any resources associated with the test_suite_base instance. It ensures that the test suite is properly cleaned up after execution, supporting robust and reliable test management across all files and folders within the µTest++ framework.

Definition at line 92 of file test-suite.cpp.

Member Function Documentation

◆ begin_test_case()

void micro_os_plus::micro_test_plus::test_suite_base::begin_test_case ( const char * name)
Parameters
[in]nameThe test case name.
Returns
Nothing.

This method marks the beginning of a test case within the suite. If the start of the suite was deferred, it ensures the suite is properly begun before proceeding. The method sets the current test case name, increments the total number of test cases, resets the current test case statistics, and notifies the test reporter to begin the test case. This approach guarantees that each test case is clearly identified, accurately tracked, and properly reported across all test cases and folders.

Definition at line 159 of file test-suite.cpp.

◆ begin_test_suite()

void micro_os_plus::micro_test_plus::test_suite_base::begin_test_suite ( void )
Parameters
None.
Returns
Nothing.

This method marks the beginning of a test suite's execution. It resets the deferred begin flag and notifies the test reporter to start the suite, passing the suite's name. This ensures that test suite output is clearly delineated and properly initialised, supporting organised and readable reporting across all test cases and folders.

Definition at line 122 of file test-suite.cpp.

◆ end_test_case()

void micro_os_plus::micro_test_plus::test_suite_base::end_test_case ( void )
Parameters
None.
Returns
Nothing.

This method marks the end of a test case within the suite. It notifies the test reporter to conclude the test case, passing the current test case name. This ensures that the results of the test case are accurately finalised and clearly reported, supporting organised and reliable test management across all test cases and folders.

Definition at line 183 of file test-suite.cpp.

◆ end_test_suite()

void micro_os_plus::micro_test_plus::test_suite_base::end_test_suite ( void )
Parameters
None.
Returns
Nothing.

This method marks the end of a test suite's execution. If the suite's start was deferred, it ensures the suite is properly begun before finalising. The method then notifies the test reporter to conclude the suite, passing a reference to the suite instance. This guarantees that all results are accurately summarised and reported, supporting clear and organised test management across all test cases and folders.

Definition at line 139 of file test-suite.cpp.

◆ failed_checks()

int micro_os_plus::micro_test_plus::test_suite_base::failed_checks ( void )
inlinenodiscardconstexpr
Parameters
None.
Returns
An integer with the number of checks that failed.

Definition at line 226 of file test-suite.h.

◆ increment_failed()

void micro_os_plus::micro_test_plus::test_suite_base::increment_failed ( void )
Parameters
None.
Returns
Nothing.

This method increments the count of failed checks for the test suite and the current test case. It ensures that each failing assertion is accurately recorded, supporting precise tracking and reporting of test outcomes across all test cases and folders.

Definition at line 210 of file test-suite.cpp.

◆ increment_successful()

void micro_os_plus::micro_test_plus::test_suite_base::increment_successful ( void )
Parameters
None.
Returns
Nothing.

This method increments the count of successful checks for the test suite and the current test case. It ensures that each passing assertion is accurately recorded, supporting precise tracking and reporting of test outcomes across all test cases and folders.

Definition at line 196 of file test-suite.cpp.

◆ name()

const char * micro_os_plus::micro_test_plus::test_suite_base::name ( void )
inlinenodiscardconstexpr
Parameters
None.
Returns
A pointer to the null-terminated test suite name.

Definition at line 178 of file test-suite.h.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ run()

void micro_os_plus::micro_test_plus::test_suite_base::run ( void )
virtual
Parameters
None.
Returns
Nothing.

This method executes the test suite by invoking its associated callable object. If tracing is enabled, the function signature is output for diagnostic purposes. The method ensures that all test cases grouped within the suite are executed in an organised manner, supporting comprehensive and structured testing across all files and folders within the µTest++ framework.

Reimplemented in micro_os_plus::micro_test_plus::test_suite.

Definition at line 106 of file test-suite.cpp.

◆ successful_checks()

int micro_os_plus::micro_test_plus::test_suite_base::successful_checks ( void )
inlinenodiscardconstexpr
Parameters
None.
Returns
An integer with the number of checks that passed.

Definition at line 213 of file test-suite.h.

◆ test_cases()

int micro_os_plus::micro_test_plus::test_suite_base::test_cases ( void )
inlinenodiscardconstexpr
Parameters
None.
Returns
An integer with the number of test cases.

Definition at line 239 of file test-suite.h.

◆ unused()

bool micro_os_plus::micro_test_plus::test_suite_base::unused ( void )
inlinenodiscardconstexpr
Parameters
None.
Returns
True if the test suite is not used.

Definition at line 288 of file test-suite.h.

◆ was_successful()

bool micro_os_plus::micro_test_plus::test_suite_base::was_successful ( void )
inlinenodiscardconstexpr
Parameters
None.
Returns
True if the test suite was successful.

Definition at line 274 of file test-suite.h.

Member Data Documentation

◆ [struct]

struct { ... } micro_os_plus::micro_test_plus::test_suite_base::current_test_case

Tracks the number of successful and failed checks for the currently running test case.

◆ failed_checks

int micro_os_plus::micro_test_plus::test_suite_base::failed_checks ( void )

Definition at line 343 of file test-suite.h.

◆ failed_checks_

int micro_os_plus::micro_test_plus::test_suite_base::failed_checks_ = 0
protected

Definition at line 313 of file test-suite.h.

◆ name_

const char* micro_os_plus::micro_test_plus::test_suite_base::name_
protected

Definition at line 298 of file test-suite.h.

◆ process_deferred_begin

bool micro_os_plus::micro_test_plus::test_suite_base::process_deferred_begin = true

Definition at line 324 of file test-suite.h.

◆ successful_checks

int micro_os_plus::micro_test_plus::test_suite_base::successful_checks ( void )

Definition at line 338 of file test-suite.h.

◆ successful_checks_

int micro_os_plus::micro_test_plus::test_suite_base::successful_checks_ = 0
protected

Definition at line 308 of file test-suite.h.

◆ test_case_name_

const char* micro_os_plus::micro_test_plus::test_suite_base::test_case_name_
protected

Definition at line 303 of file test-suite.h.

◆ test_cases_

int micro_os_plus::micro_test_plus::test_suite_base::test_cases_ = 0
protected

Definition at line 318 of file test-suite.h.


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