Skip to content

Commit a2395d4

Browse files
authored
[Core] Include stack traces in html report (#2862)
With cucumber/react-components#345 the html formatter started to support rendering stack traces. Unfortunately this also broke the regular rendering of stacktrace. And fixing this required including the stack trace the xml report as well so that when the Convertor in messages was fixed to always include the stacktrace, we wouldn't render the stacktrace in the xml formatter twice.
1 parent 9eb958d commit a2395d4

File tree

4 files changed

+6
-16
lines changed

4 files changed

+6
-16
lines changed

Diff for: CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1010
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1111

1212
## [Unreleased]
13+
### Fixed
14+
- [Core] Include stack traces in html report ([#2862](https://github.com/cucumber/cucumber-jvm/pull/2862) M.P. Korstanje)
1315

1416
## [7.16.0] - 2024-03-21
1517
### Added

Diff for: cucumber-bom/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<cucumber-expressions.version>17.1.0</cucumber-expressions.version>
1717
<gherkin.version>28.0.0</gherkin.version>
1818
<html-formatter.version>21.3.0</html-formatter.version>
19-
<junit-xml-formatter.version>0.2.1</junit-xml-formatter.version>
20-
<messages.version>24.0.1</messages.version>
19+
<junit-xml-formatter.version>0.3.0</junit-xml-formatter.version>
20+
<messages.version>24.1.0</messages.version>
2121
<tag-expressions.version>6.1.0</tag-expressions.version>
2222
</properties>
2323

Diff for: cucumber-core/src/main/java/io/cucumber/core/runner/TestStep.java

+1-12
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
import io.cucumber.plugin.event.TestStepFinished;
1111
import io.cucumber.plugin.event.TestStepStarted;
1212

13-
import java.io.ByteArrayOutputStream;
14-
import java.io.PrintStream;
15-
import java.nio.charset.StandardCharsets;
1613
import java.time.Duration;
1714
import java.time.Instant;
1815
import java.util.UUID;
@@ -117,7 +114,7 @@ private void emitTestStepFinished(
117114

118115
TestStepResult testStepResult = new TestStepResult(
119116
toMessage(duration),
120-
result.getError() != null ? extractStackTrace(result.getError()) : null,
117+
result.getError() != null ? result.getError().getMessage() : null,
121118
from(result.getStatus()),
122119
result.getError() != null ? toMessage(result.getError()) : null);
123120

@@ -128,12 +125,4 @@ private void emitTestStepFinished(
128125
toMessage(stopTime)));
129126
bus.send(envelope);
130127
}
131-
132-
private String extractStackTrace(Throwable error) {
133-
ByteArrayOutputStream s = new ByteArrayOutputStream();
134-
PrintStream printStream = new PrintStream(s);
135-
error.printStackTrace(printStream);
136-
return new String(s.toByteArray(), StandardCharsets.UTF_8);
137-
}
138-
139128
}

Diff for: cucumber-core/src/main/java/io/cucumber/core/runtime/CucumberExecutionContext.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.function.Consumer;
2525

2626
import static io.cucumber.cienvironment.DetectCiEnvironment.detectCiEnvironment;
27-
import static io.cucumber.core.exception.ExceptionUtils.printStackTrace;
2827
import static io.cucumber.core.exception.ExceptionUtils.throwAsUncheckedException;
2928
import static io.cucumber.core.exception.UnrecoverableExceptions.rethrowIfUnrecoverable;
3029
import static io.cucumber.messages.Convertor.toMessage;
@@ -118,7 +117,7 @@ private void emitTestRunFinished(Throwable exception) {
118117
bus.send(new TestRunFinished(instant, result));
119118

120119
io.cucumber.messages.types.TestRunFinished testRunFinished = new io.cucumber.messages.types.TestRunFinished(
121-
exception != null ? printStackTrace(exception) : null,
120+
exception != null ? exception.getMessage() : null,
122121
exception == null && exitStatus.isSuccess(),
123122
toMessage(instant),
124123
exception == null ? null : toMessage(exception));

0 commit comments

Comments
 (0)