OTest2
A C++ testing framework
scenariocase.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_SCENARIOCASE_H_
21 #define OTest2_INCLUDE_OTEST2_SCENARIOCASE_H_
22 
24 #include <otest2/scenario.h>
25 
26 namespace OTest2 {
27 
28 class Tags;
29 class ScenarioCaseBuilder;
30 
34 class ScenarioCase : public Scenario {
35  private:
36  struct Impl;
37  Impl* pimpl;
38  friend class ScenarioCaseBuilder;
39 
40  public:
48  explicit ScenarioCase(
49  const std::string& name_,
50  const Tags& tags_,
51  ObjectRepeaterFactoryPtr repeater_factory_);
52 
61  explicit ScenarioCase(
62  const std::string& name_,
63  const std::string& section_path_,
64  const Tags& tags_,
65  ObjectRepeaterFactoryPtr repeater_factory_);
66 
72  const std::string& name_,
73  const Tags& tags_,
74  ObjectRepeaterFactoryPtr repeater_factory_);
75 
79  virtual ~ScenarioCase();
80 
81  /* -- avoid copying */
83  const ScenarioCase&) = delete;
85  const ScenarioCase&) = delete;
86 
87  /* -- scenario */
89  TagsStack& tags_,
90  ScenarioContainerPtr parent_,
91  const RunnerFilter& filter_) const override;
92  virtual std::pair<std::string, ObjectRepeaterPtr> createRepeater(
93  const Context& context_) const override;
94  virtual void enterObject(
95  const Context& context_) const noexcept override;
96  virtual void leaveObject(
97  const Context& context_) const noexcept override;
98  virtual ScenarioIterPtr getChildren() const override;
99 };
100 
106  private:
107  struct Impl;
108  Impl* pimpl;
109 
110  public:
111  /* -- avoid copying */
113  const ScenarioCaseBuilder&) = delete;
115  const ScenarioCaseBuilder&) = delete;
116 
121  explicit ScenarioCaseBuilder(
122  const std::string& name_,
123  const Tags& tags_,
124  ObjectRepeaterFactoryPtr repeater_factory_);
125 
130  ScenarioCaseBuilder&& other_);
131 
136 
143  const std::string& name_);
144 
149 
154 };
155 
156 } /* -- namespace OTest2 */
157 
158 #endif /* -- OTest2_INCLUDE_OTEST2_SCENARIOCASE_H_ */
OTest2::ScenarioCaseBuilder::ScenarioCaseBuilder
ScenarioCaseBuilder(const ScenarioCaseBuilder &)=delete
OTest2::ScenarioCase
Scenario object of a test case.
Definition: scenariocase.h:34
OTest2::ScenarioCaseBuilder::~ScenarioCaseBuilder
~ScenarioCaseBuilder()
Dtor.
Definition: scenariocase.cpp:255
OTest2::ScenarioCaseBuilder::popSection
ScenarioCaseBuilder & popSection()
Pop section at current top.
Definition: scenariocase.cpp:276
OTest2::ScenarioCase::operator=
ScenarioCase & operator=(const ScenarioCase &)=delete
OTest2::ScenarioCase::enterObject
virtual void enterObject(const Context &context_) const noexcept override
Enter the testing object.
Definition: scenariocase.cpp:182
OTest2::RunnerFilter
Generic interface of a runner filter.
Definition: runnerfilter.h:35
OTest2::ScenarioCase::leaveObject
virtual void leaveObject(const Context &context_) const noexcept override
Report leaving of the testing object.
Definition: scenariocase.cpp:195
OTest2::ScenarioCase::getChildren
virtual ScenarioIterPtr getChildren() const override
Get iterator of children object.
Definition: scenariocase.cpp:204
OTest2::ScenarioCase::filterScenario
virtual ScenarioPtr filterScenario(TagsStack &tags_, ScenarioContainerPtr parent_, const RunnerFilter &filter_) const override
Filter the scenario.
Definition: scenariocase.cpp:149
OTest2::ScenarioCaseBuilder::operator=
ScenarioCaseBuilder & operator=(const ScenarioCaseBuilder &)=delete
objectrepeaterfactoryptr.h
OTest2::ObjectRepeaterFactoryPtr
std::shared_ptr< ObjectRepeaterFactory > ObjectRepeaterFactoryPtr
Shared pointer of the object repeater factories.
Definition: objectrepeaterfactoryptr.h:27
OTest2
Definition: assertbean.h:25
OTest2::ScenarioCase::ScenarioCase
ScenarioCase(const std::string &name_, const Tags &tags_, ObjectRepeaterFactoryPtr repeater_factory_)
Ctor.
Definition: scenariocase.cpp:121
OTest2::ScenarioIterPtr
std::shared_ptr< ScenarioIter > ScenarioIterPtr
Shared pointer of the scenario iter interface.
Definition: scenarioiterptr.h:27
OTest2::ScenarioPtr
std::shared_ptr< Scenario > ScenarioPtr
Shared pointer of the scenario object.
Definition: scenarioptr.h:27
OTest2::ScenarioCaseBuilder::getScenario
ScenarioPtr getScenario()
Get the build scenario.
Definition: scenariocase.cpp:283
OTest2::ScenarioCase::createRepeater
virtual std::pair< std::string, ObjectRepeaterPtr > createRepeater(const Context &context_) const override
Create repeater object for testing object represented by this scenario object.
Definition: scenariocase.cpp:177
scenario.h
OTest2::TagsStack
Stack of assigned tags.
Definition: tagsstack.h:36
OTest2::Tags
List of tags assigned to a testing object.
Definition: tags.h:32
OTest2::ScenarioCaseBuilder::pushSection
ScenarioCaseBuilder & pushSection(const std::string &name_)
Push a child section.
Definition: scenariocase.cpp:259
OTest2::Context
OTest2 runtime context.
Definition: context.h:38
OTest2::ScenarioContainerPtr
std::shared_ptr< ScenarioContainer > ScenarioContainerPtr
Shared pointer to a scenario container.
Definition: scenariocontainerptr.h:27
OTest2::ScenarioCase::~ScenarioCase
virtual ~ScenarioCase()
Dtor.
Definition: scenariocase.cpp:145
OTest2::ScenarioCaseBuilder
A helper class for building of a case scenario (mainly composition of test sections)
Definition: scenariocase.h:105
OTest2::ScenarioCase::createBuilder
static ScenarioCaseBuilder createBuilder(const std::string &name_, const Tags &tags_, ObjectRepeaterFactoryPtr repeater_factory_)
Create builder of the scenario case.
Definition: scenariocase.cpp:138
OTest2::Scenario
Generic scenario object.
Definition: scenario.h:47