kaycxx-test
C++ unit test framework
Loading...
Searching...
No Matches
hook.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Klaus Reimer <k@ailis.de>
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
11#include <source_location>
12#include <string>
13#include <string_view>
14
17
18namespace kaycxx::test {
19
25class hook {
26public:
34 explicit hook(std::string_view name, callback body, std::source_location location = std::source_location::current());
35
41 void run(run_options const& options = run_options());
42
43private:
45 callback body_;
46
48 std::string name_;
49
51 std::source_location location_;
52};
53
54} // namespace kaycxx::test
Defines the callback type used by the test framework.
Registered setup or teardown hook.
Definition hook.hpp:25
hook(std::string_view name, callback body, std::source_location location=std::source_location::current())
Creates a hook.
void run(run_options const &options=run_options())
Runs the hook and wraps thrown exceptions in a hook error with source location information.
Unit test framework functions and types.
Definition test.hpp:15
std::move_only_function< void()> callback
Callable block used by tests, suites, and hooks.
Definition callback.hpp:20
Defines test execution options.
Configures the execution of registered tests.
Definition run_options.hpp:14