xrpld
Loading...
Searching...
No Matches
recorder.h
1// Distributed under the Boost Software License, Version 1.0. (See accompanying
2// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
3//
4
5#pragma once
6
7#include <xrpl/beast/unit_test/results.h>
8#include <xrpl/beast/unit_test/runner.h>
9
10namespace beast::unit_test {
11
13class Recorder : public Runner
14{
15private:
19
20public:
21 Recorder() = default;
22
24 [[nodiscard]] Results const&
25 report() const
26 {
27 return results_;
28 }
29
30private:
31 void
32 onSuiteBegin(SuiteInfo const& info) override
33 {
35 }
36
37 void
38 onSuiteEnd() override
39 {
40 results_.insert(std::move(suite_));
41 }
42
43 void
44 onCaseBegin(std::string const& name) override
45 {
46 case_ = CaseResults(name);
47 }
48
49 void
50 onCaseEnd() override
51 {
52 if (!case_.tests.empty())
53 suite_.insert(std::move(case_));
54 }
55
56 void
57 onPass() override
58 {
59 case_.tests.pass();
60 }
61
62 void
63 onFail(std::string const& reason) override
64 {
65 case_.tests.fail(reason);
66 }
67
68 void
69 onLog(std::string const& s) override
70 {
71 case_.log.insert(s);
72 }
73};
74
75} // namespace beast::unit_test
Holds a set of test condition outcomes in a testcase.
Definition results.h:17
Results const & report() const
Returns a report with the results of all completed suites.
Definition recorder.h:25
void onCaseBegin(std::string const &name) override
Called when a new case starts.
Definition recorder.h:44
void onSuiteBegin(SuiteInfo const &info) override
Called when a new suite starts.
Definition recorder.h:32
void onCaseEnd() override
Called when a new case ends.
Definition recorder.h:50
void onFail(std::string const &reason) override
Called for each failing condition.
Definition recorder.h:63
void onSuiteEnd() override
Called when a suite ends.
Definition recorder.h:38
void onPass() override
Called for each passing condition.
Definition recorder.h:57
void onLog(std::string const &s) override
Called when a test logs output.
Definition recorder.h:69
Holds the results of running a set of testsuites.
Definition results.h:166
Associates a unit test type with metadata.
Definition suite_info.h:18
std::string fullName() const
Return the canonical suite name as a string.
Definition suite_info.h:72
Holds the set of testcase results in a suite.
Definition results.h:109