Skip to content

Commit a9d7bd9

Browse files
committed
🆕 Support for registering steps only for a specific scenario
1 parent c2acc34 commit a9d7bd9

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
```cpp
137137
#include <Gunit.h>
138138

139-
GSTEPS("Calc*") { // Calc Addition
139+
GSTEPS("Calc*") { // "Calc Addition.Add two numbers"
140140
double result{};
141141

142142
Given("I created a calculator with value {n}") =

docs/GSteps.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
* Synopsis
1515
```cpp
1616
/**
17-
* @param feature regex expression matching a feature name
18-
* example: "Calc*"
17+
* @param feature.scenario regex expression matching a feature name
18+
* example: "Calc*" - all scenarios from Calc feature
19+
* example: "Calc Addition.Add two numbers" - Only 'Add two numbers' scenario from Calc feature
1920
*/
20-
#define GSTEPS(feature) // register steps for a feature
21+
#define GSTEPS(name) // register steps for a feature.scenario
2122

2223
namespace testing {
2324
/**

include/GUnit/GSteps.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,9 @@ class Steps {
378378
const std::string scenario_name = pickle_json["name"];
379379
const auto tags = detail::make_tags(pickle_json["tags"]);
380380
const auto disabled = tags.first ? "DISABLED_" : "";
381+
const auto full_name = feature_name + "." + scenario_name;
381382

382-
if (PatternMatchesString(name.c_str(), feature_name.c_str())) {
383+
if (PatternMatchesString(name.c_str(), full_name.c_str())) {
383384
info_.feature = feature_name;
384385

385386
detail::MakeAndRegisterTestInfo(

test/Features/Calc/Steps/CalcSteps.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "Features/Calc/Impl/Calculator.h"
1313

1414
// clang-format off
15-
GSTEPS("Calc") {
15+
GSTEPS("Calc Addition.Add two numbers") {
1616
using namespace testing;
1717
Calculator calc{};
1818
double result{};
@@ -30,11 +30,6 @@ GSTEPS("Calc") {
3030
result = calc.add();
3131
};
3232

33-
When("I press divide"_step) =
34-
[&] {
35-
result = calc.divide();
36-
};
37-
3833
Then("the result should be {expected} on the screen"_step) =
3934
[&](double expected) {
4035
EXPECT_EQ(expected, result);

0 commit comments

Comments
 (0)