|
kaycxx-test
C++ unit test framework
|
Owns a set of test suites and the registration stack used while suite bodies execute. More...
#include <kaycxx/test/test_registry.hpp>
Public Member Functions | |
| test_registry () | |
| Creates an empty test registry. | |
| ~test_registry () | |
| Destroys the test registry and all registered suites. | |
| test_registry (test_registry const &)=delete | |
| test_registry & | operator= (test_registry const &)=delete |
| void | add_suite (std::string_view description, callback body, std::source_location location=std::source_location::current()) |
| Adds a suite and immediately executes its registration body. | |
| void | add_test (std::string_view description, callback body, std::source_location location=std::source_location::current()) |
| Adds a test case to the current suite. | |
| void | add_test (std::string_view description, skip_condition condition, callback body, std::source_location location=std::source_location::current()) |
| Adds a test case with a skip condition to the current suite. | |
| void | add_before_all_hook (hook value) |
| Adds a before_all hook to the current suite. | |
| void | add_before_each_hook (hook value) |
| Adds a before_each hook to the current suite. | |
| void | add_after_each_hook (hook value) |
| Adds an after_each hook to the current suite. | |
| void | add_after_all_hook (hook value) |
| Adds an after_all hook to the current suite. | |
| bool | run (reporter &reporter, run_options const &options={}) |
| Executes all registered top-level suites in declaration order. | |
| bool | run (reporter &reporter, test_filter const &filter, run_options const &options={}) |
| Executes registered tests selected by a filter. | |
| std::vector< std::string > | list_tests () const |
| Lists all registered test cases in execution order. | |
| std::vector< std::string > | list_tests (test_filter const &filter) const |
| Lists registered test cases selected by a filter in execution order. | |
| std::size_t | num_test_suites () const |
| Returns the number of all registered top-level and nested suites. | |
| std::size_t | num_test_suites (test_filter const &filter) const |
| Returns the number of suites containing tests selected by a filter. | |
| std::size_t | num_test_cases () const |
| Returns the number of all registered test cases. | |
| std::size_t | num_test_cases (test_filter const &filter) const |
| Returns the number of test cases selected by a filter. | |
Owns a set of test suites and the registration stack used while suite bodies execute.
| void kaycxx::test::test_registry::add_after_all_hook | ( | hook | value | ) |
Adds an after_all hook to the current suite.
| value | Hook to register. |
| void kaycxx::test::test_registry::add_after_each_hook | ( | hook | value | ) |
Adds an after_each hook to the current suite.
| value | Hook to register. |
| void kaycxx::test::test_registry::add_before_all_hook | ( | hook | value | ) |
Adds a before_all hook to the current suite.
| value | Hook to register. |
| void kaycxx::test::test_registry::add_before_each_hook | ( | hook | value | ) |
Adds a before_each hook to the current suite.
| value | Hook to register. |
| void kaycxx::test::test_registry::add_suite | ( | std::string_view | description, |
| callback | body, | ||
| std::source_location | location = std::source_location::current() |
||
| ) |
Adds a suite and immediately executes its registration body.
If no suite is currently active, this adds a top-level suite. Otherwise it adds a nested suite to the current suite.
| description | Human-readable suite description. |
| body | Registration callback that defines child suites, tests, and hooks. |
| location | Source location of the suite declaration. |
| void kaycxx::test::test_registry::add_test | ( | std::string_view | description, |
| callback | body, | ||
| std::source_location | location = std::source_location::current() |
||
| ) |
Adds a test case to the current suite.
| description | Human-readable test description. |
| body | Test callback to execute. |
| location | Source location of the test registration. |
| void kaycxx::test::test_registry::add_test | ( | std::string_view | description, |
| skip_condition | condition, | ||
| callback | body, | ||
| std::source_location | location = std::source_location::current() |
||
| ) |
Adds a test case with a skip condition to the current suite.
| description | Human-readable test description. |
| condition | Condition deciding if the test should be skipped. |
| body | Test callback to execute. |
| location | Source location of the test registration. |
| std::vector< std::string > kaycxx::test::test_registry::list_tests | ( | ) | const |
Lists all registered test cases in execution order.
Duplicate full descriptions are returned only once.
| std::vector< std::string > kaycxx::test::test_registry::list_tests | ( | test_filter const & | filter | ) | const |
Lists registered test cases selected by a filter in execution order.
| filter | Test selection filter. Duplicate full descriptions are returned only once. |
| std::size_t kaycxx::test::test_registry::num_test_cases | ( | ) | const |
Returns the number of all registered test cases.
| std::size_t kaycxx::test::test_registry::num_test_cases | ( | test_filter const & | filter | ) | const |
Returns the number of test cases selected by a filter.
| filter | Test selection filter. |
| std::size_t kaycxx::test::test_registry::num_test_suites | ( | ) | const |
Returns the number of all registered top-level and nested suites.
| std::size_t kaycxx::test::test_registry::num_test_suites | ( | test_filter const & | filter | ) | const |
Returns the number of suites containing tests selected by a filter.
| filter | Test selection filter. |
| bool kaycxx::test::test_registry::run | ( | reporter & | reporter, |
| run_options const & | options = {} |
||
| ) |
Executes all registered top-level suites in declaration order.
| reporter | Reporter receiving lifecycle events. |
| options | Test execution options. |
| bool kaycxx::test::test_registry::run | ( | reporter & | reporter, |
| test_filter const & | filter, | ||
| run_options const & | options = {} |
||
| ) |
Executes registered tests selected by a filter.
Suites without selected tests are not executed or reported. Suite hooks execute once for each selected suite.
| reporter | Reporter receiving lifecycle events. |
| filter | Test selection filter. |
| options | Test execution options. |