Skip to content

Commit

Permalink
[Core] Include stack traces in html report
Browse files Browse the repository at this point in the history
  • Loading branch information
mpkorstanje committed Mar 23, 2024
1 parent 9eb958d commit 1200c25
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

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

## [7.16.0] - 2024-03-21
### Added
Expand Down
4 changes: 2 additions & 2 deletions cucumber-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<cucumber-expressions.version>17.1.0</cucumber-expressions.version>
<gherkin.version>28.0.0</gherkin.version>
<html-formatter.version>21.3.0</html-formatter.version>
<junit-xml-formatter.version>0.2.1</junit-xml-formatter.version>
<messages.version>24.0.1</messages.version>
<junit-xml-formatter.version>0.3.0</junit-xml-formatter.version>
<messages.version>24.1.0</messages.version>
<tag-expressions.version>6.1.0</tag-expressions.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void emitTestStepFinished(

TestStepResult testStepResult = new TestStepResult(
toMessage(duration),
result.getError() != null ? extractStackTrace(result.getError()) : null,
result.getError() != null ? result.getError().getMessage() : null,
from(result.getStatus()),
result.getError() != null ? toMessage(result.getError()) : null);

Expand All @@ -128,12 +128,4 @@ private void emitTestStepFinished(
toMessage(stopTime)));
bus.send(envelope);
}

private String extractStackTrace(Throwable error) {
ByteArrayOutputStream s = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(s);
error.printStackTrace(printStream);
return new String(s.toByteArray(), StandardCharsets.UTF_8);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.function.Consumer;

import static io.cucumber.cienvironment.DetectCiEnvironment.detectCiEnvironment;
import static io.cucumber.core.exception.ExceptionUtils.printStackTrace;
import static io.cucumber.core.exception.ExceptionUtils.throwAsUncheckedException;
import static io.cucumber.core.exception.UnrecoverableExceptions.rethrowIfUnrecoverable;
import static io.cucumber.messages.Convertor.toMessage;
Expand Down Expand Up @@ -118,7 +117,7 @@ private void emitTestRunFinished(Throwable exception) {
bus.send(new TestRunFinished(instant, result));

io.cucumber.messages.types.TestRunFinished testRunFinished = new io.cucumber.messages.types.TestRunFinished(
exception != null ? printStackTrace(exception) : null,
exception != null ? exception.getMessage() : null,
exception == null && exitStatus.isSuccess(),
toMessage(instant),
exception == null ? null : toMessage(exception));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class MessageStepDefinitions {
public void the_user_has_posted_the_message(String content) {
User user = userStepDefinitions.getCurrentUser();
messageRepository.save(new Message(user, content));
throw new RuntimeException("Boom");
}

@Given("a User has posted the following messages:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import org.junit.platform.suite.api.Suite;

import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME;
import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME;

@Suite
@IncludeEngines("cucumber")
@SelectPackages("io.cucumber.examples.spring.application")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "io.cucumber.examples.spring.application")
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "html:target/report-after.html, junit:target/junit-after.xml")
public class RunCucumberTest {
}

0 comments on commit 1200c25

Please sign in to comment.