Skip to content

Commit 5165064

Browse files
committed
Include pickle name if parameterized
1 parent ba4a73b commit 5165064

File tree

6 files changed

+38
-14
lines changed

6 files changed

+38
-14
lines changed

cucumber-core/src/test/java/io/cucumber/core/plugin/TeamCityPluginTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void should_handle_scenario_outline() {
7272
"##teamcity[testSuiteStarted timestamp = '1970-01-01T12:00:00.000+0000' locationHint = '" + location
7373
+ "path/test.feature:5' name = 'examples name']\n" +
7474
"##teamcity[testSuiteStarted timestamp = '1970-01-01T12:00:00.000+0000' locationHint = '" + location
75-
+ "path/test.feature:7' name = 'Example #1.1']\n" +
75+
+ "path/test.feature:7' name = 'Example #1.1 - name 1']\n" +
7676
"##teamcity[customProgressStatus type = 'testStarted' timestamp = '1970-01-01T12:00:00.000+0000']\n" +
7777
"##teamcity[testStarted timestamp = '1970-01-01T12:00:00.000+0000' locationHint = '" + location
7878
+ "path/test.feature:3' captureStandardOutput = 'true' name = 'first step']\n" +
@@ -83,9 +83,10 @@ void should_handle_scenario_outline() {
8383
"##teamcity[testFinished timestamp = '1970-01-01T12:00:00.000+0000' duration = '0' name = 'second step']\n"
8484
+
8585
"##teamcity[customProgressStatus type = 'testFinished' timestamp = '1970-01-01T12:00:00.000+0000']\n" +
86-
"##teamcity[testSuiteFinished timestamp = '1970-01-01T12:00:00.000+0000' name = 'Example #1.1']\n" +
86+
"##teamcity[testSuiteFinished timestamp = '1970-01-01T12:00:00.000+0000' name = 'Example #1.1 - name 1']\n"
87+
+
8788
"##teamcity[testSuiteStarted timestamp = '1970-01-01T12:00:00.000+0000' locationHint = '" + location
88-
+ "path/test.feature:8' name = 'Example #1.2']\n" +
89+
+ "path/test.feature:8' name = 'Example #1.2 - name 2']\n" +
8990
"##teamcity[customProgressStatus type = 'testStarted' timestamp = '1970-01-01T12:00:00.000+0000']\n" +
9091
"##teamcity[testStarted timestamp = '1970-01-01T12:00:00.000+0000' locationHint = '" + location
9192
+ "path/test.feature:3' captureStandardOutput = 'true' name = 'first step']\n" +
@@ -96,7 +97,8 @@ void should_handle_scenario_outline() {
9697
"##teamcity[testFinished timestamp = '1970-01-01T12:00:00.000+0000' duration = '0' name = 'third step']\n"
9798
+
9899
"##teamcity[customProgressStatus type = 'testFinished' timestamp = '1970-01-01T12:00:00.000+0000']\n" +
99-
"##teamcity[testSuiteFinished timestamp = '1970-01-01T12:00:00.000+0000' name = 'Example #1.2']\n" +
100+
"##teamcity[testSuiteFinished timestamp = '1970-01-01T12:00:00.000+0000' name = 'Example #1.2 - name 2']\n"
101+
+
100102
"##teamcity[customProgressStatus testsCategory = '' count = '0' timestamp = '1970-01-01T12:00:00.000+0000']\n"
101103
+
102104
"##teamcity[testSuiteFinished timestamp = '1970-01-01T12:00:00.000+0000' name = 'examples name']\n" +

cucumber-gherkin-messages/src/main/java/io/cucumber/core/gherkin/messages/GherkinMessagesExample.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88

99
final class GherkinMessagesExample implements Node.Example {
1010

11+
private final GherkinMessagesFeature feature;
1112
private final TableRow tableRow;
1213
private final int examplesIndex;
1314
private final int rowIndex;
1415
private final Node parent;
1516

16-
GherkinMessagesExample(Node parent, TableRow tableRow, int examplesIndex, int rowIndex) {
17+
GherkinMessagesExample(
18+
GherkinMessagesFeature feature, Node parent, TableRow tableRow, int examplesIndex, int rowIndex
19+
) {
20+
this.feature = feature;
1721
this.parent = parent;
1822
this.tableRow = tableRow;
1923
this.examplesIndex = examplesIndex;
@@ -32,7 +36,18 @@ public Optional<String> getKeyword() {
3236

3337
@Override
3438
public Optional<String> getName() {
35-
return Optional.of("Example #" + examplesIndex + "." + rowIndex);
39+
String pickleName = feature.getPickleAt(this).getName();
40+
boolean parameterized = !parent.getParent()
41+
.filter(GherkinMessagesScenarioOutline.class::isInstance)
42+
.flatMap(Node::getName)
43+
.map(pickleName::equals)
44+
.orElse(true);
45+
46+
StringBuilder builder = new StringBuilder("Example #" + examplesIndex + "." + rowIndex);
47+
if (parameterized) {
48+
builder.append(" - ").append(pickleName);
49+
}
50+
return Optional.of(builder.toString());
3651
}
3752

3853
@Override

cucumber-gherkin-messages/src/main/java/io/cucumber/core/gherkin/messages/GherkinMessagesExamples.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@
1111

1212
final class GherkinMessagesExamples implements Node.Examples {
1313

14+
private final GherkinMessagesFeature feature;
1415
private final io.cucumber.messages.types.Examples examples;
1516
private final List<Example> children;
1617
private final Location location;
1718
private final Node parent;
1819

19-
GherkinMessagesExamples(Node parent, io.cucumber.messages.types.Examples examples, int examplesIndex) {
20+
GherkinMessagesExamples(
21+
GherkinMessagesFeature feature, Node parent, io.cucumber.messages.types.Examples examples, int examplesIndex
22+
) {
23+
this.feature = feature;
2024
this.parent = parent;
2125
this.examples = examples;
2226
this.location = GherkinMessagesLocation.from(examples.getLocation());
2327
AtomicInteger row = new AtomicInteger(1);
2428
this.children = examples.getTableBody().stream()
25-
.map(tableRow -> new GherkinMessagesExample(this, tableRow, examplesIndex, row.getAndIncrement()))
29+
.map(tableRow -> new GherkinMessagesExample(feature, this, tableRow, examplesIndex,
30+
row.getAndIncrement()))
2631
.collect(Collectors.toList());
2732
}
2833

cucumber-gherkin-messages/src/main/java/io/cucumber/core/gherkin/messages/GherkinMessagesFeature.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ final class GherkinMessagesFeature implements Feature {
4646

4747
private Node mapRuleOrScenario(FeatureChild featureChild) {
4848
if (featureChild.getRule().isPresent()) {
49-
return new GherkinMessagesRule(this, featureChild.getRule().get());
49+
return new GherkinMessagesRule(this, this, featureChild.getRule().get());
5050
}
5151

5252
io.cucumber.messages.types.Scenario scenario = featureChild.getScenario().get();
5353
if (!scenario.getExamples().isEmpty()) {
54-
return new GherkinMessagesScenarioOutline(this, scenario);
54+
return new GherkinMessagesScenarioOutline(this, this, scenario);
5555
}
5656
return new GherkinMessagesScenario(this, scenario);
5757
}

cucumber-gherkin-messages/src/main/java/io/cucumber/core/gherkin/messages/GherkinMessagesRule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class GherkinMessagesRule implements Node.Rule {
1515
private final io.cucumber.messages.types.Rule rule;
1616
private final List<Node> children;
1717

18-
GherkinMessagesRule(Node parent, io.cucumber.messages.types.Rule rule) {
18+
GherkinMessagesRule(GherkinMessagesFeature feature, Node parent, io.cucumber.messages.types.Rule rule) {
1919
this.parent = parent;
2020
this.rule = rule;
2121
this.children = rule.getChildren().stream()
@@ -24,7 +24,7 @@ final class GherkinMessagesRule implements Node.Rule {
2424
.map(Optional::get)
2525
.map(scenario -> {
2626
if (!scenario.getExamples().isEmpty()) {
27-
return new GherkinMessagesScenarioOutline(this, scenario);
27+
return new GherkinMessagesScenarioOutline(feature, this, scenario);
2828
} else {
2929
return new GherkinMessagesScenario(this, scenario);
3030
}

cucumber-gherkin-messages/src/main/java/io/cucumber/core/gherkin/messages/GherkinMessagesScenarioOutline.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ final class GherkinMessagesScenarioOutline implements Node.ScenarioOutline {
1515
private final List<Examples> children;
1616
private final Node parent;
1717

18-
GherkinMessagesScenarioOutline(Node parent, io.cucumber.messages.types.Scenario scenario) {
18+
GherkinMessagesScenarioOutline(
19+
GherkinMessagesFeature feature, Node parent, io.cucumber.messages.types.Scenario scenario
20+
) {
1921
this.parent = parent;
2022
this.scenario = scenario;
2123
AtomicInteger examplesIndex = new AtomicInteger(1);
2224
this.children = scenario.getExamples().stream()
23-
.map(examples -> new GherkinMessagesExamples(this, examples, examplesIndex.getAndIncrement()))
25+
.map(examples -> new GherkinMessagesExamples(feature, this, examples, examplesIndex.getAndIncrement()))
2426
.collect(Collectors.toList());
2527
}
2628

0 commit comments

Comments
 (0)