Skip to content

Commit

Permalink
cucumber tables will now appear in report json / html report #1035
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Jan 25, 2020
1 parent d5e07e2 commit 736360e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion karate-core/src/main/java/com/intuit/karate/core/StepResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ private static Map<String, Object> docStringToMap(int line, String text) {
map.put("value", text);
return map;
}

private static List<Map> tableToMap(Table table) {
List<List<String>> rows = table.getRows();
List<Map> list = new ArrayList(rows.size());
int count = rows.size();
for (int i = 0; i < count; i++) {
List<String> row = rows.get(i);
Map<String, Object> map = new HashMap(2);
map.put("cells", row);
map.put("line", table.getLineNumberForRow(i));
list.add(map);
}
return list;
}

public StepResult(Map<String, Object> map) {
json = map;
Expand All @@ -95,7 +109,7 @@ public Map<String, Object> toMap() {
if (json != null) {
return json;
}
Map<String, Object> map = new HashMap(7);
Map<String, Object> map = new HashMap(8);
map.put("line", step.getLine());
map.put("keyword", step.getPrefix());
map.put("name", step.getText());
Expand All @@ -114,6 +128,9 @@ public Map<String, Object> toMap() {
if (sb.length() > 0) {
map.put("doc_string", docStringToMap(step.getLine(), sb.toString()));
}
if (step.getTable() != null) {
map.put("rows", tableToMap(step.getTable()));
}
if (embeds != null) {
List<Map> embedList = new ArrayList(embeds.size());
for (Embed embed : embeds) {
Expand Down

0 comments on commit 736360e

Please sign in to comment.