Skip to content

Commit a280f2f

Browse files
committed
Added explicit check for empty scenario outline example steps after tokenisation
1 parent cb1c984 commit a280f2f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

core/src/main/java/cucumber/runtime/model/CucumberScenarioOutline.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cucumber.runtime.model;
22

3+
import cucumber.runtime.CucumberException;
34
import cucumber.runtime.Runtime;
45
import gherkin.formatter.Formatter;
56
import gherkin.formatter.Reporter;
@@ -103,13 +104,17 @@ private static DocString docStringWithTokensReplaced(DocString docString, List<S
103104
}
104105

105106
private static String replaceTokens(Set<Integer> matchedColumns, List<String> headerCells, List<String> exampleCells, String text) {
106-
for (int i = 0; i < headerCells.size(); i++) {
107-
String headerCell = headerCells.get(i);
108-
String value = exampleCells.get(i);
107+
for (int col = 0; col < headerCells.size(); col++) {
108+
String headerCell = headerCells.get(col);
109+
String value = exampleCells.get(col);
109110
String token = "<" + headerCell + ">";
111+
110112
if (text.contains(token)) {
111113
text = text.replace(token, value);
112-
matchedColumns.add(i);
114+
if (text.isEmpty()) {
115+
throw new CucumberException("Step generated from scenario outline '" + token + "' is empty");
116+
}
117+
matchedColumns.add(col);
113118
}
114119
}
115120
return text;

0 commit comments

Comments
 (0)