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#include <xrpl/beast/unit_test/suite_info.h>
10
11#include <string>
12#include <utility>
13
14namespace beast::unit_test {
15
19class Recorder : public Runner
20{
21private:
25
26public:
27 Recorder() = default;
28
32 [[nodiscard]] Results const&
33 report() const
34 {
35 return results_;
36 }
37
38private:
39 void
40 onSuiteBegin(SuiteInfo const& info) override
41 {
43 }
44
45 void
46 onSuiteEnd() override
47 {
48 results_.insert(std::move(suite_));
49 }
50
51 void
52 onCaseBegin(std::string const& name) override
53 {
54 case_ = CaseResults(name);
55 }
56
57 void
58 onCaseEnd() override
59 {
60 if (!case_.tests.empty())
61 suite_.insert(std::move(case_));
62 }
63
64 void
65 onPass() override
66 {
67 case_.tests.pass();
68 }
69
70 void
71 onFail(std::string const& reason) override
72 {
73 case_.tests.fail(reason);
74 }
75
76 void
77 onLog(std::string const& s) override
78 {
79 case_.log.insert(s);
80 }
81};
82
83} // namespace beast::unit_test
Holds a set of test condition outcomes in a testcase.
Definition results.h:20
Results const & report() const
Returns a report with the results of all completed suites.
Definition recorder.h:33
void onCaseBegin(std::string const &name) override
Called when a new case starts.
Definition recorder.h:52
void onSuiteBegin(SuiteInfo const &info) override
Called when a new suite starts.
Definition recorder.h:40
void onCaseEnd() override
Called when a new case ends.
Definition recorder.h:58
void onFail(std::string const &reason) override
Called for each failing condition.
Definition recorder.h:71
void onSuiteEnd() override
Called when a suite ends.
Definition recorder.h:46
void onPass() override
Called for each passing condition.
Definition recorder.h:65
void onLog(std::string const &s) override
Called when a test logs output.
Definition recorder.h:77
Holds the results of running a set of testsuites.
Definition results.h:199
Associates a unit test type with metadata.
Definition suite_info.h:20
std::string fullName() const
Return the canonical suite name as a string.
Definition suite_info.h:78
Holds the set of testcase results in a suite.
Definition results.h:132