rippled
Loading...
Searching...
No Matches
recorder.h
1//
2// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7
8#ifndef BEAST_UNIT_TEST_RECORDER_HPP
9#define BEAST_UNIT_TEST_RECORDER_HPP
10
11#include <xrpl/beast/unit_test/results.h>
12#include <xrpl/beast/unit_test/runner.h>
13
14namespace beast {
15namespace unit_test {
16
18class recorder : public runner
19{
20private:
24
25public:
26 recorder() = default;
27
29 results const&
30 report() const
31 {
32 return m_results;
33 }
34
35private:
36 virtual void
37 on_suite_begin(suite_info const& info) override
38 {
40 }
41
42 virtual void
43 on_suite_end() override
44 {
45 m_results.insert(std::move(m_suite));
46 }
47
48 virtual void
49 on_case_begin(std::string const& name) override
50 {
51 m_case = case_results(name);
52 }
53
54 virtual void
55 on_case_end() override
56 {
57 if (m_case.tests.size() > 0)
58 m_suite.insert(std::move(m_case));
59 }
60
61 virtual void
62 on_pass() override
63 {
65 }
66
67 virtual void
68 on_fail(std::string const& reason) override
69 {
70 m_case.tests.fail(reason);
71 }
72
73 virtual void
74 on_log(std::string const& s) override
75 {
76 m_case.log.insert(s);
77 }
78};
79
80} // namespace unit_test
81} // namespace beast
82
83#endif
void insert(std::string const &s)
Insert a string into the log.
Definition results.h:85
void pass()
Register a successful test condition.
Definition results.h:66
void fail(std::string const &reason="")
Register a failed test condition.
Definition results.h:73
Holds a set of test condition outcomes in a testcase.
Definition results.h:21
tests_t tests
Memberspace for a container of test condition outcomes.
Definition results.h:106
log_t log
Memberspace for a container of testcase log messages.
Definition results.h:109
size_type size() const
Returns the number of items in the container.
A test runner that stores the results.
Definition recorder.h:19
results const & report() const
Returns a report with the results of all completed suites.
Definition recorder.h:30
virtual void on_suite_end() override
Called when a suite ends.
Definition recorder.h:43
virtual void on_fail(std::string const &reason) override
Called for each failing condition.
Definition recorder.h:68
virtual void on_case_end() override
Called when a new case ends.
Definition recorder.h:55
suite_results m_suite
Definition recorder.h:22
virtual void on_case_begin(std::string const &name) override
Called when a new case starts.
Definition recorder.h:49
virtual void on_suite_begin(suite_info const &info) override
Called when a new suite starts.
Definition recorder.h:37
virtual void on_pass() override
Called for each passing condition.
Definition recorder.h:62
virtual void on_log(std::string const &s) override
Called when a test logs output.
Definition recorder.h:74
Holds the results of running a set of testsuites.
Definition results.h:173
void insert(suite_results &&r)
Insert a set of suite results.
Definition results.h:208
Unit test runner interface.
Definition runner.h:27
Associates a unit test type with metadata.
Definition suite_info.h:23
std::string full_name() const
Return the canonical suite name as a string.
Definition suite_info.h:77
Holds the set of testcase results in a suite.
Definition results.h:116
void insert(case_results &&r)
Insert a set of testcase results.
Definition results.h:151