rippled
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#ifndef BEAST_UNIT_TEST_RECORDER_HPP
6#define BEAST_UNIT_TEST_RECORDER_HPP
7
8#include <xrpl/beast/unit_test/results.h>
9#include <xrpl/beast/unit_test/runner.h>
10
11namespace beast {
12namespace unit_test {
13
15class recorder : public runner
16{
17private:
21
22public:
23 recorder() = default;
24
26 results const&
27 report() const
28 {
29 return m_results;
30 }
31
32private:
33 virtual void
34 on_suite_begin(suite_info const& info) override
35 {
37 }
38
39 virtual void
40 on_suite_end() override
41 {
42 m_results.insert(std::move(m_suite));
43 }
44
45 virtual void
46 on_case_begin(std::string const& name) override
47 {
48 m_case = case_results(name);
49 }
50
51 virtual void
52 on_case_end() override
53 {
54 if (m_case.tests.size() > 0)
55 m_suite.insert(std::move(m_case));
56 }
57
58 virtual void
59 on_pass() override
60 {
62 }
63
64 virtual void
65 on_fail(std::string const& reason) override
66 {
67 m_case.tests.fail(reason);
68 }
69
70 virtual void
71 on_log(std::string const& s) override
72 {
73 m_case.log.insert(s);
74 }
75};
76
77} // namespace unit_test
78} // namespace beast
79
80#endif
void insert(std::string const &s)
Insert a string into the log.
Definition results.h:82
void pass()
Register a successful test condition.
Definition results.h:63
void fail(std::string const &reason="")
Register a failed test condition.
Definition results.h:70
Holds a set of test condition outcomes in a testcase.
Definition results.h:18
tests_t tests
Memberspace for a container of test condition outcomes.
Definition results.h:103
log_t log
Memberspace for a container of testcase log messages.
Definition results.h:106
size_type size() const
Returns the number of items in the container.
A test runner that stores the results.
Definition recorder.h:16
results const & report() const
Returns a report with the results of all completed suites.
Definition recorder.h:27
virtual void on_suite_end() override
Called when a suite ends.
Definition recorder.h:40
virtual void on_fail(std::string const &reason) override
Called for each failing condition.
Definition recorder.h:65
virtual void on_case_end() override
Called when a new case ends.
Definition recorder.h:52
suite_results m_suite
Definition recorder.h:19
virtual void on_case_begin(std::string const &name) override
Called when a new case starts.
Definition recorder.h:46
virtual void on_suite_begin(suite_info const &info) override
Called when a new suite starts.
Definition recorder.h:34
virtual void on_pass() override
Called for each passing condition.
Definition recorder.h:59
virtual void on_log(std::string const &s) override
Called when a test logs output.
Definition recorder.h:71
Holds the results of running a set of testsuites.
Definition results.h:170
void insert(suite_results &&r)
Insert a set of suite results.
Definition results.h:205
Unit test runner interface.
Definition runner.h:24
Associates a unit test type with metadata.
Definition suite_info.h:20
std::string full_name() const
Return the canonical suite name as a string.
Definition suite_info.h:74
Holds the set of testcase results in a suite.
Definition results.h:113
void insert(case_results &&r)
Insert a set of testcase results.
Definition results.h:148