11
22#include " cucumber_cpp/library/engine/TestRunner.hpp"
3+ #include " cucumber_cpp/library/BodyMacro.hpp"
34#include " cucumber_cpp/library/engine/FeatureFactory.hpp"
45#include " cucumber_cpp/library/engine/FeatureInfo.hpp"
56#include " cucumber_cpp/library/engine/RuleInfo.hpp"
@@ -37,10 +38,15 @@ namespace cucumber_cpp::library::engine
3738
3839 void TestRunnerImpl::Run (const std::vector<std::unique_ptr<FeatureInfo>>& feature)
3940 {
40- auto scope = testExecution.StartRun ();
41+ auto run = [this , &feature]
42+ {
43+ auto scope = testExecution.StartRun ();
4144
42- for (const auto & featurePtr : feature)
43- RunFeature (*featurePtr);
45+ for (const auto & featurePtr : feature)
46+ RunFeature (*featurePtr);
47+ };
48+
49+ ASSERT_NO_THROW (run ());
4450 }
4551
4652 void TestRunnerImpl::NestedStep (StepType type, std::string step)
@@ -51,20 +57,28 @@ namespace cucumber_cpp::library::engine
5157
5258 void TestRunnerImpl::RunFeature (const FeatureInfo& feature)
5359 {
54- if (feature.Rules ().empty () && feature.Scenarios ().empty ())
55- return ;
60+ auto run = [this , &feature]
61+ {
62+ if (feature.Rules ().empty () && feature.Scenarios ().empty ())
63+ return ;
5664
57- const auto featureScope = testExecution.StartFeature (feature);
65+ const auto featureScope = testExecution.StartFeature (feature);
5866
59- RunRules (feature.Rules ());
60- RunScenarios (feature.Scenarios ());
67+ RunRules (feature.Rules ());
68+ RunScenarios (feature.Scenarios ());
69+ };
70+ ASSERT_NO_THROW (run ());
6171 }
6272
6373 void TestRunnerImpl::RunRule (const RuleInfo& rule)
6474 {
65- const auto ruleScope = testExecution.StartRule (rule);
75+ auto run = [this , &rule]
76+ {
77+ const auto ruleScope = testExecution.StartRule (rule);
6678
67- RunScenarios (rule.Scenarios ());
79+ RunScenarios (rule.Scenarios ());
80+ };
81+ ASSERT_NO_THROW (run ());
6882 }
6983
7084 void TestRunnerImpl::RunRules (const std::vector<std::unique_ptr<RuleInfo>>& rules)
@@ -75,11 +89,15 @@ namespace cucumber_cpp::library::engine
7589
7690 void TestRunnerImpl::RunScenario (const ScenarioInfo& scenario)
7791 {
78- const auto scenarioScope = testExecution.StartScenario (scenario);
92+ auto run = [this , &scenario]
93+ {
94+ const auto scenarioScope = testExecution.StartScenario (scenario);
7995
80- currentScenario = &scenario;
96+ currentScenario = &scenario;
8197
82- ExecuteSteps (scenario);
98+ ExecuteSteps (scenario);
99+ };
100+ ASSERT_NO_THROW (run ());
83101 }
84102
85103 void TestRunnerImpl::RunScenarios (const std::vector<std::unique_ptr<ScenarioInfo>>& scenarios)
0 commit comments