Skip to content

Commit

Permalink
fixed #293
Browse files Browse the repository at this point in the history
  • Loading branch information
bischoffdev committed Sep 27, 2022
1 parent ceb3965 commit c6f4855
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 34 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

Back to [Readme](README.md).

## [2.9.2] - 2022-09-27

### Fixed
* #293 - unescaped html in exception messages

## [2.9.1] - 2022-09-26

### Added
Expand Down Expand Up @@ -649,6 +654,7 @@ steps with status `pending` or `undefined` (default value is `false`) (#74)

Initial project version on GitHub and Maven Central.

[2.9.2]: https://github.com/trivago/cluecumber-report-plugin/tree/2.9.2
[2.9.1]: https://github.com/trivago/cluecumber-report-plugin/tree/2.9.1
[2.9.0]: https://github.com/trivago/cluecumber-report-plugin/tree/2.9.0
[2.8.0]: https://github.com/trivago/cluecumber-report-plugin/tree/2.8.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"name": "this step fails",
"result": {
"duration": 340604218,
"error_message": "java.lang.RuntimeException: this step failed\n\tat Steps.lambda$new$2(Steps.java:14)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)",
"error_message": "java.lang.RuntimeException <b>Something</b>: this step failed\n\tat Steps.lambda$new$2(Steps.java:14)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)",
"status": "failed"
},
"embeddings": [
Expand Down
2 changes: 1 addition & 1 deletion example-project/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>blog.softwaretester</groupId>
<artifactId>cluecumber-test-project</artifactId>
<version>2.9.1</version>
<version>2.9.2</version>
<packaging>pom</packaging>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion plugin-code/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.trivago.rta</groupId>
<artifactId>cluecumber-report-plugin</artifactId>
<version>2.9.1</version>
<version>2.9.2</version>
<url>https://github.com/trivago/cluecumber-report-plugin</url>

<name>Cluecumber Maven Plugin for Cucumber Reports</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@SuppressWarnings("unused")
Expand Down Expand Up @@ -287,47 +288,54 @@ public String getFirstExceptionClass() {
}

public String getFirstException() {
for (ResultMatch beforeHook : before) {
if (beforeHook.isFailed()) {
return beforeHook.getResult().getErrorMessage();
}
String exception = getResultListException(before);
if (exception != null){
return exception;
}
for (Step step : backgroundSteps) {
for (ResultMatch beforeStepHook : step.getBefore()) {
if (beforeStepHook.isFailed()) {
return beforeStepHook.getResult().getErrorMessage();
}
}
if (step.isFailed()) {
return step.getResult().getErrorMessage();
}
for (ResultMatch afterStepHook : step.getAfter()) {
if (afterStepHook.isFailed()) {
return afterStepHook.getResult().getErrorMessage();
}
}

exception = getStepException(backgroundSteps);
if (exception != null){
return exception;
}

exception = getStepException(steps);
if (exception != null){
return RenderingUtils.escapeHTML(exception);
}

exception = getResultListException(after);
if (exception != null){
return exception;
}
return "";
}

private String getStepException(final List<Step> steps) {
for (Step step : steps) {
for (ResultMatch beforeStepHook : step.getBefore()) {
if (beforeStepHook.isFailed()) {
return beforeStepHook.getResult().getErrorMessage();
}
String exception = getResultListException(step.getBefore());
if (exception != null){
return exception;
}

if (step.isFailed()) {
return step.getResult().getErrorMessage();
}
for (ResultMatch afterStepHook : step.getAfter()) {
if (afterStepHook.isFailed()) {
return afterStepHook.getResult().getErrorMessage();
}

exception = getResultListException(step.getAfter());
if (exception != null){
return exception;
}
}
for (ResultMatch afterHook : after) {
if (afterHook.isFailed()) {
return afterHook.getResult().getErrorMessage();
return null;
}

private String getResultListException(final List<ResultMatch> resultMatches) {
for (ResultMatch match : resultMatches) {
if (match.isFailed()) {
return RenderingUtils.escapeHTML(match.getResult().getErrorMessage());
}
}
return "";
return null;
}

public int getScenarioIndex() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ limitations under the License.
</#if>
</#macro>

<#macro output step>
<#macro output step>
<#if step.hasOutputs()>
<div class="row w-100 p-3 m-0 scenarioOutput">
<div class="w-100 text-left small p-2">${step.returnEscapedOutputs()?join("<br><br>")}</div>
Expand Down

0 comments on commit c6f4855

Please sign in to comment.