OTest2
A C++ testing framework
reporterjunit.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Ondrej Starek
3  *
4  * This file is part of OTest2.
5  *
6  * OTest2 is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License,
9  * or (at your option) any later version.
10  *
11  * OTest2 is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with OTest2. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OTest2__INCLUDE_OTEST2_REPORTERJUNIT_H_
21 #define OTest2__INCLUDE_OTEST2_REPORTERJUNIT_H_
22 
23 #include <string>
24 
25 #include <otest2/reporter.h>
26 
27 namespace OTest2 {
28 
32 class ReporterJUnit : public Reporter {
33  private:
34  struct Impl;
35  Impl* pimpl;
36 
37  public:
45  explicit ReporterJUnit(
46  const std::string& file_,
47  bool hide_location_);
48 
52  virtual ~ReporterJUnit();
53 
54  /* -- avoid copying */
56  const ReporterJUnit&) = delete;
58  const ReporterJUnit&) = delete;
59 
60  /* -- reporter interface */
61  virtual void enterTest(
62  const Context& context_,
63  const std::string& name_,
64  const Parameters& params_) override;
65  virtual void enterSuite(
66  const Context& context_,
67  const std::string& name_,
68  const Parameters& params_) override;
69  virtual void enterCase(
70  const Context& context_,
71  const std::string& name_,
72  const Parameters& params_) override;
73  virtual void enterState(
74  const Context& context_,
75  const std::string& name_) override;
77  const Context& context_,
78  bool condition_,
79  const std::string& file_,
80  int lineno_) override;
82  const Context& context_) override;
83  virtual void leaveState(
84  const Context& context_,
85  const std::string& name_,
86  bool result_) override;
87  virtual void leaveCase(
88  const Context& context_,
89  const std::string& name_,
90  const Parameters& params_,
91  bool result_) override;
92  virtual void leaveSuite(
93  const Context& context_,
94  const std::string& name_,
95  const Parameters& params_,
96  bool result_) override;
97  virtual void leaveTest(
98  const Context& context_,
99  const std::string& name_,
100  const Parameters& params_,
101  bool result_) override;
102 };
103 
104 } /* -- namespace OTest2 */
105 
106 #endif /* -- OTest2__INCLUDE_OTEST2_REPORTERJUNIT_H_ */
OTest2::ReporterJUnit::enterSuite
virtual void enterSuite(const Context &context_, const std::string &name_, const Parameters &params_) override
Enter a suite.
Definition: reporterjunit.cpp:317
OTest2::ReporterJUnit::~ReporterJUnit
virtual ~ReporterJUnit()
Dtor.
Definition: reporterjunit.cpp:292
OTest2::Reporter
Generic test reporter.
Definition: reporter.h:34
reporter.h
OTest2::ReporterJUnit::enterError
virtual AssertBufferPtr enterError(const Context &context_) override
Enter an error report.
Definition: reporterjunit.cpp:376
OTest2::ReporterJUnit::operator=
ReporterJUnit & operator=(const ReporterJUnit &)=delete
OTest2::ReporterJUnit::leaveTest
virtual void leaveTest(const Context &context_, const std::string &name_, const Parameters &params_, bool result_) override
Leave entire test.
Definition: reporterjunit.cpp:427
OTest2::Parameters
Generic parameters of a run of an testing object.
Definition: parameters.h:30
OTest2::ReporterJUnit::enterTest
virtual void enterTest(const Context &context_, const std::string &name_, const Parameters &params_) override
Enter entire test.
Definition: reporterjunit.cpp:296
OTest2
Definition: assertbean.h:25
OTest2::ReporterJUnit::enterCase
virtual void enterCase(const Context &context_, const std::string &name_, const Parameters &params_) override
Enter a case.
Definition: reporterjunit.cpp:335
OTest2::ReporterJUnit::ReporterJUnit
ReporterJUnit(const std::string &file_, bool hide_location_)
Ctor.
Definition: reporterjunit.cpp:285
OTest2::ReporterJUnit::leaveSuite
virtual void leaveSuite(const Context &context_, const std::string &name_, const Parameters &params_, bool result_) override
Leave a suite.
Definition: reporterjunit.cpp:411
OTest2::ReporterJUnit
A reporter creating JUnit XML reports.
Definition: reporterjunit.h:32
OTest2::Context
OTest2 runtime context.
Definition: context.h:38
OTest2::ReporterJUnit::leaveCase
virtual void leaveCase(const Context &context_, const std::string &name_, const Parameters &params_, bool result_) override
Leave a case.
Definition: reporterjunit.cpp:396
OTest2::AssertBufferPtr
std::shared_ptr< AssertBuffer > AssertBufferPtr
Definition: assertbufferptr.h:27
OTest2::ReporterJUnit::enterAssert
virtual AssertBufferPtr enterAssert(const Context &context_, bool condition_, const std::string &file_, int lineno_) override
Enter an assertion.
Definition: reporterjunit.cpp:358
OTest2::ReporterJUnit::enterState
virtual void enterState(const Context &context_, const std::string &name_) override
Enter a state.
Definition: reporterjunit.cpp:352
OTest2::ReporterJUnit::leaveState
virtual void leaveState(const Context &context_, const std::string &name_, bool result_) override
Leave a state.
Definition: reporterjunit.cpp:389