Skip to content

Commit 6a2492c

Browse files
committed
Refactored RunCucumber
1 parent ba22049 commit 6a2492c

21 files changed

+39
-38
lines changed

cucumber_cpp/library/api/RunCucumber.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "cucumber/gherkin/id_generator.hpp"
33
#include "cucumber/messages/location.hpp"
44
#include "cucumber/messages/parameter_type.hpp"
5+
#include "cucumber/messages/source_reference.hpp"
56
#include "cucumber/messages/step_definition.hpp"
67
#include "cucumber/messages/step_definition_pattern.hpp"
78
#include "cucumber_cpp/CucumberCpp.hpp"
@@ -28,7 +29,7 @@ namespace cucumber_cpp::library::api
2829
{
2930
namespace
3031
{
31-
void EmitParameters(support::SupportCodeLibrary supportCodeLibrary, util::Broadcaster& broadcaster, cucumber::gherkin::id_generator_ptr idGenerator)
32+
void EmitParameters(support::SupportCodeLibrary& supportCodeLibrary, util::Broadcaster& broadcaster, cucumber::gherkin::id_generator_ptr idGenerator)
3233
{
3334
for (const auto& [name, parameter] : supportCodeLibrary.parameterRegistry.GetParameters())
3435
{
@@ -52,13 +53,13 @@ namespace cucumber_cpp::library::api
5253
}
5354
}
5455

55-
void EmitUndefinedParameters(support::SupportCodeLibrary supportCodeLibrary, util::Broadcaster& broadcaster)
56+
void EmitUndefinedParameters(support::SupportCodeLibrary& supportCodeLibrary, util::Broadcaster& broadcaster)
5657
{
5758
for (const auto& parameter : supportCodeLibrary.undefinedParameters.definitions)
5859
broadcaster.BroadcastEvent({ .undefined_parameter_type = parameter });
5960
}
6061

61-
void EmitStepDefinitions(support::SupportCodeLibrary supportCodeLibrary, util::Broadcaster& broadcaster, cucumber::gherkin::id_generator_ptr idGenerator)
62+
void EmitStepDefinitions(support::SupportCodeLibrary& supportCodeLibrary, util::Broadcaster& broadcaster)
6263
{
6364
for (const auto& stepDefinition : supportCodeLibrary.stepRegistry.StepDefinitions())
6465
{
@@ -78,7 +79,7 @@ namespace cucumber_cpp::library::api
7879
}
7980
}
8081

81-
void EmitTestCaseHooks(support::SupportCodeLibrary supportCodeLibrary, util::Broadcaster& broadcaster)
82+
void EmitTestCaseHooks(support::SupportCodeLibrary& supportCodeLibrary, util::Broadcaster& broadcaster)
8283
{
8384
const auto beforeAllHooks = supportCodeLibrary.hookRegistry.HooksByType(HookType::before);
8485

@@ -91,7 +92,7 @@ namespace cucumber_cpp::library::api
9192
broadcaster.BroadcastEvent({ .hook = std::move(hook) });
9293
}
9394

94-
void EmitTestRunHooks(support::SupportCodeLibrary supportCodeLibrary, util::Broadcaster& broadcaster)
95+
void EmitTestRunHooks(support::SupportCodeLibrary& supportCodeLibrary, util::Broadcaster& broadcaster)
9596
{
9697
const auto beforeAllHooks = supportCodeLibrary.hookRegistry.HooksByType(HookType::beforeAll);
9798

@@ -104,15 +105,15 @@ namespace cucumber_cpp::library::api
104105
broadcaster.BroadcastEvent({ .hook = std::move(hook) });
105106
}
106107

107-
void EmitSupportCodeMessages(support::SupportCodeLibrary supportCodeLibrary, util::Broadcaster& broadcaster, cucumber::gherkin::id_generator_ptr idGenerator)
108+
void EmitSupportCodeMessages(support::SupportCodeLibrary& supportCodeLibrary, util::Broadcaster& broadcaster, cucumber::gherkin::id_generator_ptr idGenerator)
108109
{
109110
EmitParameters(supportCodeLibrary, broadcaster, idGenerator);
110111

111112
support::DefinitionRegistration::Instance().LoadIds(idGenerator);
112113
supportCodeLibrary.stepRegistry.LoadSteps();
113114

114115
EmitUndefinedParameters(supportCodeLibrary, broadcaster);
115-
EmitStepDefinitions(supportCodeLibrary, broadcaster, idGenerator);
116+
EmitStepDefinitions(supportCodeLibrary, broadcaster);
116117

117118
supportCodeLibrary.hookRegistry.LoadHooks();
118119
EmitTestCaseHooks(supportCodeLibrary, broadcaster);

cucumber_cpp/library/assemble/AssembleTestSuites.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ namespace cucumber_cpp::library::assemble
4040
return pair.second.has_value();
4141
}
4242

43-
void AssembleBeforeHooks(support::SupportCodeLibrary supportCodeLibrary, const support::PickleSource& pickleSource, cucumber::messages::test_case& testCase, cucumber::gherkin::id_generator_ptr idGenerator)
43+
void AssembleBeforeHooks(support::SupportCodeLibrary& supportCodeLibrary, const support::PickleSource& pickleSource, cucumber::messages::test_case& testCase, cucumber::gherkin::id_generator_ptr idGenerator)
4444
{
4545
for (const auto& hookId : supportCodeLibrary.hookRegistry.FindIds(HookType::before, pickleSource.pickle->tags))
4646
testCase.test_steps.emplace_back(hookId, idGenerator->next_id());
4747
}
4848

49-
void AssembleAfterHooks(support::SupportCodeLibrary supportCodeLibrary, const support::PickleSource& pickleSource, cucumber::messages::test_case& testCase, cucumber::gherkin::id_generator_ptr idGenerator)
49+
void AssembleAfterHooks(support::SupportCodeLibrary& supportCodeLibrary, const support::PickleSource& pickleSource, cucumber::messages::test_case& testCase, cucumber::gherkin::id_generator_ptr idGenerator)
5050
{
5151
for (const auto& hookId : supportCodeLibrary.hookRegistry.FindIds(HookType::after, pickleSource.pickle->tags) | std::views::reverse)
5252
testCase.test_steps.emplace_back(hookId, idGenerator->next_id());
5353
}
5454

55-
void AssembleSteps(support::SupportCodeLibrary supportCodeLibrary, const support::PickleSource& pickleSource, cucumber::messages::test_case& testCase, cucumber::gherkin::id_generator_ptr idGenerator)
55+
void AssembleSteps(support::SupportCodeLibrary& supportCodeLibrary, const support::PickleSource& pickleSource, cucumber::messages::test_case& testCase, cucumber::gherkin::id_generator_ptr idGenerator)
5656
{
5757
for (const auto& step : pickleSource.pickle->steps)
5858
{
@@ -77,15 +77,15 @@ namespace cucumber_cpp::library::assemble
7777
}
7878
}
7979

80-
void AssembleTestSteps(support::SupportCodeLibrary supportCodeLibrary, const support::PickleSource& pickleSource, cucumber::messages::test_case& testCase, cucumber::gherkin::id_generator_ptr idGenerator)
80+
void AssembleTestSteps(support::SupportCodeLibrary& supportCodeLibrary, const support::PickleSource& pickleSource, cucumber::messages::test_case& testCase, cucumber::gherkin::id_generator_ptr idGenerator)
8181
{
8282
AssembleBeforeHooks(supportCodeLibrary, pickleSource, testCase, idGenerator);
8383
AssembleSteps(supportCodeLibrary, pickleSource, testCase, idGenerator);
8484
AssembleAfterHooks(supportCodeLibrary, pickleSource, testCase, idGenerator);
8585
}
8686
}
8787

88-
std::vector<AssembledTestSuite> AssembleTestSuites(support::SupportCodeLibrary supportCodeLibrary,
88+
std::vector<AssembledTestSuite> AssembleTestSuites(support::SupportCodeLibrary& supportCodeLibrary,
8989
std::string_view testRunStartedId,
9090
util::Broadcaster& broadcaster,
9191
const std::list<support::PickleSource>& sourcedPickles,

cucumber_cpp/library/assemble/AssembleTestSuites.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace cucumber_cpp::library::assemble
1414
{
1515
std::vector<AssembledTestSuite> AssembleTestSuites(
16-
support::SupportCodeLibrary supportCodeLibrary,
16+
support::SupportCodeLibrary& supportCodeLibrary,
1717
std::string_view testRunStartedId,
1818
util::Broadcaster& broadcaster,
1919
const std::list<support::PickleSource>& sourcedPickles,

cucumber_cpp/library/formatter/Formatter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace cucumber_cpp::library::formatter
1010
{
11-
Formatter::Formatter(support::SupportCodeLibrary supportCodeLibrary, util::Broadcaster& broadcaster, const helper::EventDataCollector& eventDataCollector, std::ostream& outputStream)
11+
Formatter::Formatter(support::SupportCodeLibrary& supportCodeLibrary, util::Broadcaster& broadcaster, const helper::EventDataCollector& eventDataCollector, std::ostream& outputStream)
1212
: util::Listener{ broadcaster, [this](const cucumber::messages::envelope& envelope)
1313
{
1414
OnEnvelope(envelope);

cucumber_cpp/library/formatter/Formatter.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ namespace cucumber_cpp::library::formatter
1414
struct Formatter
1515
: util::Listener
1616
{
17-
Formatter(support::SupportCodeLibrary supportCodeLibrary, util::Broadcaster& broadcaster, const helper::EventDataCollector& eventDataCollector, std::ostream& outputStream = std::cout);
17+
Formatter(support::SupportCodeLibrary& supportCodeLibrary, util::Broadcaster& broadcaster, const helper::EventDataCollector& eventDataCollector, std::ostream& outputStream = std::cout);
1818
virtual ~Formatter() = default;
1919

2020
protected:
2121
virtual void OnEnvelope(const cucumber::messages::envelope& envelope) = 0;
2222

23-
support::SupportCodeLibrary supportCodeLibrary;
23+
support::SupportCodeLibrary& supportCodeLibrary;
2424
util::Broadcaster& broadcaster;
2525
const helper::EventDataCollector& eventDataCollector;
2626
std::ostream& outputStream;

cucumber_cpp/library/formatter/helper/IssueHelpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
namespace cucumber_cpp::library::formatter::helper
1818
{
19-
std::ostream& FormatIssue(std::ostream& outputStream, std::size_t number, const TestCaseAttempt& testCaseAttempt, support::SupportCodeLibrary supportCodeLibrary, bool printAttachments)
19+
std::ostream& FormatIssue(std::ostream& outputStream, std::size_t number, const TestCaseAttempt& testCaseAttempt, support::SupportCodeLibrary& supportCodeLibrary, bool printAttachments)
2020
{
2121
using std::operator""sv;
2222

cucumber_cpp/library/formatter/helper/IssueHelpers.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace cucumber_cpp::library::formatter::helper
1111
{
12-
std::ostream& FormatIssue(std::ostream& outputStream, std::size_t number, const TestCaseAttempt& testCaseAttempt, support::SupportCodeLibrary supportCodeLibrary, bool printAttachments = true);
12+
std::ostream& FormatIssue(std::ostream& outputStream, std::size_t number, const TestCaseAttempt& testCaseAttempt, support::SupportCodeLibrary& supportCodeLibrary, bool printAttachments = true);
1313
}
1414

1515
#endif

cucumber_cpp/library/formatter/helper/TestCaseAttemptFormatter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace cucumber_cpp::library::formatter::helper
8080
}
8181
}
8282

83-
std::string FormatTestCaseAttempt(support::SupportCodeLibrary supportCodeLibrary, const TestCaseAttempt& testCaseAttempt, bool printAttachments)
83+
std::string FormatTestCaseAttempt(support::SupportCodeLibrary& supportCodeLibrary, const TestCaseAttempt& testCaseAttempt, bool printAttachments)
8484
{
8585
const auto parsed = ParseTestCaseAttempt(supportCodeLibrary, testCaseAttempt);
8686

cucumber_cpp/library/formatter/helper/TestCaseAttemptFormatter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace cucumber_cpp::library::formatter::helper
99
{
10-
std::string FormatTestCaseAttempt(support::SupportCodeLibrary supportCodeLibrary, const TestCaseAttempt& testCaseAttempt, bool printAttachments);
10+
std::string FormatTestCaseAttempt(support::SupportCodeLibrary& supportCodeLibrary, const TestCaseAttempt& testCaseAttempt, bool printAttachments);
1111
}
1212

1313
#endif

cucumber_cpp/library/formatter/helper/TestCaseAttemptParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ namespace cucumber_cpp::library::formatter::helper
7777
}
7878
}
7979

80-
ParsedTestCaseAttempt ParseTestCaseAttempt(support::SupportCodeLibrary supportCodeLibrary, const TestCaseAttempt& testCaseAttempt)
80+
ParsedTestCaseAttempt ParseTestCaseAttempt(support::SupportCodeLibrary& supportCodeLibrary, const TestCaseAttempt& testCaseAttempt)
8181
{
8282
const auto& testCase = testCaseAttempt.testCase;
8383
const auto& pickle = testCaseAttempt.pickle;

0 commit comments

Comments
 (0)