Skip to content

Message based json formatter #2888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8cb50c2
WIP
mpkorstanje Apr 18, 2024
d8ea3b4
WIP
mpkorstanje Apr 18, 2024
799cea7
WIP
mpkorstanje Apr 18, 2024
209fc9f
WIP
mpkorstanje Apr 18, 2024
73e0763
Some greens
mpkorstanje Apr 19, 2024
eeaa600
Some greens
mpkorstanje Apr 19, 2024
352549c
Some greens
mpkorstanje Apr 19, 2024
e9c9e9b
Some greens
mpkorstanje Apr 20, 2024
d4d14f1
Merge remote-tracking branch 'origin/main' into message-based-json-fo…
mpkorstanje May 24, 2024
d93b0a0
WIP
mpkorstanje May 24, 2024
3fc0f97
Merge remote-tracking branch 'origin/main' into message-based-json-fo…
mpkorstanje Jul 5, 2025
89d2775
Fixup
mpkorstanje Jul 5, 2025
c374460
Fix a few tests
mpkorstanje Jul 5, 2025
5eb1e2e
WIP
mpkorstanje Jul 7, 2025
e200a2a
Merge remote-tracking branch 'origin/main' into message-based-json-fo…
mpkorstanje Jul 13, 2025
f573701
Fixed hooks
mpkorstanje Jul 13, 2025
465f9d6
Add methods
mpkorstanje Jul 13, 2025
3fbce35
Spotless
mpkorstanje Jul 13, 2025
bb6c6fc
Fix ordering
mpkorstanje Jul 13, 2025
280622e
Fix methods
mpkorstanje Jul 13, 2025
67ecaee
Spotless
mpkorstanje Jul 13, 2025
d30c519
Fix missing rule id segment in json formatter implementation
mpkorstanje Jul 13, 2025
c04fc95
Improve performance
mpkorstanje Jul 13, 2025
fb87cf1
Simplify hooks
mpkorstanje Jul 15, 2025
c8a525b
Simplify
mpkorstanje Jul 15, 2025
3abb8b3
Simplify
mpkorstanje Jul 15, 2025
72af87d
Extract formatters
mpkorstanje Jul 15, 2025
e96fad1
Order and formatting
mpkorstanje Jul 15, 2025
431fe2d
Resolve nulls
mpkorstanje Jul 15, 2025
f89a084
Resolve nulls
mpkorstanje Jul 15, 2025
5fe806e
Resolve nulls
mpkorstanje Jul 15, 2025
90bc96f
Extract inners
mpkorstanje Jul 15, 2025
b504efd
Touch ups
mpkorstanje Jul 15, 2025
2e1fc68
Remove old
mpkorstanje Jul 15, 2025
9aa6c3c
Merge remote-tracking branch 'origin/main' into message-based-json-fo…
mpkorstanje Jul 15, 2025
d41694f
Clean up
mpkorstanje Jul 15, 2025
80d4205
Clean up
mpkorstanje Jul 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.cucumber.core.plugin;

import io.cucumber.messages.types.Examples;
import io.cucumber.messages.types.Feature;
import io.cucumber.messages.types.Pickle;
import io.cucumber.messages.types.Rule;
import io.cucumber.messages.types.Scenario;
import io.cucumber.messages.types.TableRow;
import io.cucumber.query.LineageReducer;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;

class IdNamingVisitor implements LineageReducer.Collector<String> {

private static final Pattern replacementPattern = Pattern.compile("[\\s'_,!]");

private final List<String> parts = new ArrayList<>();

@Override
public void add(Feature feature) {
parts.add(formatId(feature.getName()));
}

@Override
public void add(Rule rule) {
parts.add(formatId(rule.getName()));
}

@Override
public void add(Scenario scenario) {
parts.add(formatId(scenario.getName()));
}

@Override
public void add(Examples examples, int index) {
parts.add(formatId(examples.getName()));
}

@Override
public void add(TableRow example, int index) {
// json report uses base-1 indexing, and skips the first row
parts.add(String.valueOf(index + 2));
}

@Override
public void add(Pickle pickle) {
formatId(pickle.getName());
}

@Override
public String finish() {
return String.join(";", parts);
}

static String formatId(String name) {
return replacementPattern.matcher(name).replaceAll("-").toLowerCase(Locale.ROOT);
}
}
Loading
Loading