Skip to content

Commit 6a592fa

Browse files
authored
Bump Cucumber to version 7.11.1 (#145)
1 parent 920b147 commit 6a592fa

File tree

5 files changed

+31
-32
lines changed

5 files changed

+31
-32
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<lombok.version>1.18.22</lombok.version>
4040
<testcontainer.version>1.16.2</testcontainer.version>
4141
<mockserver.version>5.13.2</mockserver.version>
42-
<cucumber.version>7.2.3</cucumber.version>
42+
<cucumber.version>7.11.1</cucumber.version>
4343
<commonstext.version>1.10.0</commonstext.version>
4444
<sonar.organization>decathlon</sonar.organization>
4545
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

tzatziki-core/src/main/java/com/decathlon/tzatziki/steps/ObjectSteps.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ private Map<String, String> getExamples(Scenario scenario) {
248248
.filter(stack -> stack.getClass().getSimpleName().equals("GherkinMessagesExamples"))
249249
.map(o -> getValue(o, "examples"))
250250
.map(Examples.class::cast)
251-
.map(examples -> examples.getTableHeader().getCells())
251+
.flatMap(examples -> examples.getTableHeader().map(TableRow::getCells).stream())
252252
.findFirst().orElseThrow();
253253
List<TableCell> values = currentStack.stream()
254254
.filter(stack -> stack.getClass().getSimpleName().equals("GherkinMessagesExample"))

tzatziki-core/src/main/java/io/cucumber/core/plugin/JsonFormatter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.decathlon.tzatziki.utils.Guard;
44
import com.decathlon.tzatziki.utils.Patterns;
5-
import io.cucumber.messages.JSON;
65
import io.cucumber.messages.types.Background;
76
import io.cucumber.messages.types.Feature;
87
import io.cucumber.messages.types.Scenario;
@@ -159,7 +158,7 @@ private void finishReport(TestRunFinished event) {
159158
// ↑
160159

161160
try {
162-
JSON.writeValue(writer, featureMaps);
161+
Jackson.OBJECT_MAPPER.writeValue(writer, featureMaps);
163162
writer.close();
164163
} catch (IOException e) {
165164
throw new RuntimeException(e);

tzatziki-core/src/main/java/io/cucumber/core/plugin/PrettyFormatter.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public final class PrettyFormatter implements ConcurrentEventListener, ColorAwar
4141
private final ThreadLocal<List<Node>> currentStack = ThreadLocal.withInitial(ArrayList::new);
4242
// ↑
4343

44-
private final NiceAppendable out;
44+
private final UTF8PrintWriter out;
4545
private Formats formats = ansi();
4646

4747
public PrettyFormatter(OutputStream out) {
48-
this.out = new NiceAppendable(new UTF8OutputStreamWriter(out));
48+
this.out = new UTF8PrintWriter(out);
4949
}
5050

5151
@Override
@@ -203,14 +203,20 @@ private void printError(Result result) {
203203
}
204204

205205
private void printText(WriteEvent event) {
206+
// Prevent interleaving when multiple threads write to System.out
207+
StringBuilder builder = new StringBuilder();
206208
try (BufferedReader lines = new BufferedReader(new StringReader(event.getText()))) {
207209
String line;
208210
while ((line = lines.readLine()) != null) {
209-
out.println(STEP_SCENARIO_INDENT + line);
211+
builder.append(STEP_SCENARIO_INDENT)
212+
.append(line)
213+
// Add system line separator - \n won't do it!
214+
.append(System.lineSeparator());
210215
}
211216
} catch (IOException e) {
212217
throw new CucumberException(e);
213218
}
219+
out.append(builder);
214220
}
215221

216222
private void printEmbedding(EmbedEvent event) {

tzatziki-core/src/main/java/io/cucumber/core/runner/TestStep.java

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
import io.cucumber.core.eventbus.EventBus;
55
import io.cucumber.messages.types.Envelope;
66
import io.cucumber.messages.types.TestStepResult;
7-
import io.cucumber.plugin.event.Result;
8-
import io.cucumber.plugin.event.Status;
97
import io.cucumber.plugin.event.TestCase;
10-
import io.cucumber.plugin.event.TestStepFinished;
11-
import io.cucumber.plugin.event.TestStepStarted;
8+
import io.cucumber.plugin.event.*;
129

1310
import java.io.ByteArrayOutputStream;
1411
import java.io.PrintStream;
@@ -21,9 +18,8 @@
2118
import static io.cucumber.core.exception.UnrecoverableExceptions.rethrowIfUnrecoverable;
2219
import static io.cucumber.core.runner.ExecutionMode.SKIP;
2320
import static io.cucumber.core.runner.TestAbortedExceptions.createIsTestAbortedExceptionPredicate;
24-
import static io.cucumber.core.runner.TestStepResultStatus.from;
25-
import static io.cucumber.messages.TimeConversion.javaDurationToDuration;
26-
import static io.cucumber.messages.TimeConversion.javaInstantToTimestamp;
21+
import static io.cucumber.core.runner.TestStepResultStatusMapper.from;
22+
import static io.cucumber.messages.Convertor.toMessage;
2723
import static java.time.Duration.ZERO;
2824

2925
abstract class TestStep implements io.cucumber.plugin.event.TestStep {
@@ -72,11 +68,10 @@ ExecutionMode run(TestCase testCase, EventBus bus, TestCaseState state, Executio
7268

7369
private void emitTestStepStarted(TestCase testCase, EventBus bus, UUID textExecutionId, Instant startTime) {
7470
bus.send(new TestStepStarted(startTime, testCase, this));
75-
Envelope envelope = new Envelope();
76-
envelope.setTestStepStarted(new io.cucumber.messages.types.TestStepStarted(
77-
textExecutionId.toString(),
78-
id.toString(),
79-
javaInstantToTimestamp(startTime)));
71+
Envelope envelope = Envelope.of(new io.cucumber.messages.types.TestStepStarted(
72+
textExecutionId.toString(),
73+
id.toString(),
74+
toMessage(startTime)));
8075
bus.send(envelope);
8176
}
8277

@@ -117,19 +112,18 @@ private void emitTestStepFinished(
117112
) {
118113
bus.send(new TestStepFinished(stopTime, testCase, this, result));
119114

120-
TestStepResult testStepResult = new TestStepResult();
121-
if (result.getError() != null) {
122-
testStepResult.setMessage(extractStackTrace(result.getError()));
123-
}
124-
testStepResult.setStatus(from(result.getStatus()));
125-
testStepResult.setDuration(javaDurationToDuration(duration));
126-
127-
Envelope envelope = new Envelope();
128-
envelope.setTestStepFinished(new io.cucumber.messages.types.TestStepFinished(
129-
textExecutionId.toString(),
130-
id.toString(),
131-
testStepResult,
132-
javaInstantToTimestamp(stopTime)));
115+
TestStepResult testStepResult = new TestStepResult(
116+
toMessage(duration),
117+
result.getError() != null ? extractStackTrace(result.getError()) : null,
118+
from(result.getStatus()),
119+
result.getError() != null ? toMessage(result.getError()) : null
120+
);
121+
122+
Envelope envelope = Envelope.of(new io.cucumber.messages.types.TestStepFinished(
123+
textExecutionId.toString(),
124+
id.toString(),
125+
testStepResult,
126+
toMessage(stopTime)));
133127
bus.send(envelope);
134128
}
135129

0 commit comments

Comments
 (0)