Skip to content

Commit

Permalink
Merge pull request #264 from trivago/bugfixes
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
Benjamin Bischoff authored Nov 27, 2020
2 parents 2948302 + 8a34561 commit 1c2aaa1
Show file tree
Hide file tree
Showing 12 changed files with 225 additions and 77 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

Back to [Readme](README.md).

## [2.6.0] - 2020-11-27

### Fixed
* Fixed HTML encoding for attachments (#263)

### Added
* Background steps are now displayed in a separate section of the report

### Changed
* Only hooks with outputs are considered and displayed in the scenario detail pages (#211)
* Various design cleanups

## [2.5.0] - 2020-05-11

### Added
Expand Down
4 changes: 2 additions & 2 deletions example-project/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.benjamin-bischoff</groupId>
<artifactId>cluecumber-test-project</artifactId>
<version>2.5.0</version>
<version>2.6.0</version>
<packaging>pom</packaging>

<properties>
Expand Down Expand Up @@ -34,7 +34,7 @@
</executions>
<configuration>
<!-- The only two mandatory properties -->
<sourceJsonReportDirectory>${cucumber.report.json.location}/TEST.json</sourceJsonReportDirectory>
<sourceJsonReportDirectory>${cucumber.report.json.location}</sourceJsonReportDirectory>
<generatedHtmlReportDirectory>${generated.report.location}</generatedHtmlReportDirectory>

<!-- Optional custom parameters that are shown on the start page (if they have a value) -->
Expand Down
9 changes: 5 additions & 4 deletions 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.5.0</version>
<version>2.6.0</version>
<url>https://github.com/trivago/cluecumber-report-plugin</url>

<name>Cluecumber Maven Plugin for Cucumber Reports</name>
Expand Down Expand Up @@ -80,9 +80,10 @@
<maven.plugin.annotations.version>3.6.0</maven.plugin.annotations.version>
<maven.source.plugin.version>2.4</maven.source.plugin.version>
<plexus.utilities.version>3.3.0</plexus.utilities.version>
<jacoco.version>0.8.4</jacoco.version>

<mockito.version>3.3.3</mockito.version>
<junit5.vintage.version>5.7.0-M1</junit5.vintage.version>
<mockito.version>3.6.28</mockito.version>
<junit5.vintage.version>5.7.0</junit5.vintage.version>
<openpojo.version>0.8.13</openpojo.version>

<gson.version>2.8.6</gson.version>
Expand Down Expand Up @@ -141,7 +142,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<version>${jacoco.version}</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class Element {
private List<ResultMatch> after = new ArrayList<>();
private String type = "";
private String keyword = "";
private List<Step> backgroundSteps = new ArrayList<>();
private List<Step> steps = new ArrayList<>();
private List<Tag> tags = new ArrayList<>();
@SerializedName("start_timestamp")
Expand Down Expand Up @@ -98,6 +99,15 @@ public void setBefore(final List<ResultMatch> before) {
this.before = before;
}

public boolean anyBeforeHookHasContent() {
for (ResultMatch resultMatch : before) {
if (resultMatch.hasContent()) {
return true;
}
}
return false;
}

public int getLine() {
return line;
}
Expand Down Expand Up @@ -138,6 +148,15 @@ public void setAfter(final List<ResultMatch> after) {
this.after = after;
}

public boolean anyAfterHookHasContent() {
for (ResultMatch resultMatch : before) {
if (resultMatch.hasContent()) {
return true;
}
}
return false;
}

public String getType() {
return type;
}
Expand All @@ -162,6 +181,14 @@ public void setSteps(final List<Step> steps) {
this.steps = steps;
}

public List<Step> getBackgroundSteps() {
return backgroundSteps;
}

public void setBackgroundSteps(final List<Step> steps) {
this.backgroundSteps = steps;
}

public boolean isScenario() {
return type.equals("scenario");
}
Expand Down Expand Up @@ -278,6 +305,7 @@ private int getNumberOfStepsWithStatus(final Status status) {

public long getTotalDuration() {
long totalDurationNanoseconds = before.stream().mapToLong(beforeStep -> beforeStep.getResult().getDuration()).sum();
totalDurationNanoseconds += backgroundSteps.stream().mapToLong(Step::getTotalDuration).sum();
totalDurationNanoseconds += steps.stream().mapToLong(Step::getTotalDuration).sum();
totalDurationNanoseconds += after.stream().mapToLong(afterStep -> afterStep.getResult().getDuration()).sum();
return totalDurationNanoseconds;
Expand All @@ -292,6 +320,11 @@ public boolean hasHooks() {
}

public boolean hasDocStrings() {
for (Step step : backgroundSteps) {
if (step.getDocString() != null) {
return true;
}
}
for (Step step : steps) {
if (step.getDocString() != null) {
return true;
Expand All @@ -301,6 +334,14 @@ public boolean hasDocStrings() {
}

public boolean hasStepHooks() {
for (Step step : backgroundSteps) {
if (step.getBefore().size() > 0) {
return true;
}
if (step.getAfter().size() > 0) {
return true;
}
}
for (Step step : steps) {
if (step.getBefore().size() > 0) {
return true;
Expand All @@ -314,6 +355,7 @@ public boolean hasStepHooks() {

public List<ResultMatch> getAllResultMatches() {
List<ResultMatch> resultMatches = new ArrayList<>(getBefore());
resultMatches.addAll(getBackgroundSteps());
resultMatches.addAll(getSteps());
resultMatches.addAll(getAfter());
return resultMatches;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public void decodeData(final String data) {
decodedData = new String(Base64.decodeBase64(data.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
switch (mimeType) {
case HTML:
decodedData = decodedData.replaceAll("\"", "'");
decodedData = decodedData.replaceAll("\"", "'")
.replaceAll("&", "&amp;")
.replaceAll("\"", "&quot;");
break;
case XML:
case APPLICATION_XML:
Expand Down Expand Up @@ -92,12 +94,12 @@ public void setFilename(final String filename) {

public boolean isImage() {
return mimeType == MimeType.PNG ||
mimeType == MimeType.GIF ||
mimeType == MimeType.BMP ||
mimeType == MimeType.JPEG ||
mimeType == MimeType.JPG ||
mimeType == MimeType.SVG ||
mimeType == MimeType.SVG_XML;
mimeType == MimeType.GIF ||
mimeType == MimeType.BMP ||
mimeType == MimeType.JPEG ||
mimeType == MimeType.JPG ||
mimeType == MimeType.SVG ||
mimeType == MimeType.SVG_XML;
}

public boolean isPlainText() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public void setEmbeddings(final List<Embedding> embeddings) {
this.embeddings = embeddings;
}

public boolean hasEmbeddings() {
return embeddings.size() > 0;
}

public List<String> getOutput() {
return output;
}
Expand Down Expand Up @@ -96,6 +100,10 @@ public boolean isSkipped() {
return getConsolidatedStatus() == Status.SKIPPED;
}

public boolean hasContent() {
return hasOutputs() || hasEmbeddings();
}

public Status getConsolidatedStatus() {
switch (getStatus()) {
case PASSED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.gson.JsonElement;
import com.trivago.cluecumber.json.pojo.Element;
import com.trivago.cluecumber.json.pojo.Report;
import com.trivago.cluecumber.json.pojo.Step;
import com.trivago.cluecumber.json.pojo.Tag;
import io.gsonfire.PostProcessor;

Expand Down Expand Up @@ -66,19 +67,19 @@ private void addFeatureInformationToScenarios(final Report report) {
}

private void mergeBackgroundScenarios(final Report report) {
List<Element> cleanedUpElements = new ArrayList<>();
Element currentBackgroundElement = null;
List<Element> updatedElements = new ArrayList<>();
List<Step> currentBackgroundSteps = null;
for (Element element : report.getElements()) {
if (element.getType().equalsIgnoreCase("background")) {
currentBackgroundElement = element;
currentBackgroundSteps = element.getSteps();
} else {
if (currentBackgroundElement != null) {
element.getSteps().addAll(0, currentBackgroundElement.getSteps());
if (currentBackgroundSteps != null) {
element.setBackgroundSteps(currentBackgroundSteps);
}
cleanedUpElements.add(element);
updatedElements.add(element);
}
}
report.setElements(cleanedUpElements);
report.setElements(updatedElements);
}

private void addFeatureIndex(final Report report) {
Expand Down
19 changes: 13 additions & 6 deletions plugin-code/src/main/resources/template/css/cluecumber.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,18 @@ pre {
padding: 1rem;
}

.list-group {
margin-bottom: auto;
}

.list-group-item .row:hover {
background-color: rgba(0, 0, 0, .075);
}

.list-group-flush .list-group-item:last-child {
margin-bottom: 0;
}

div.tooltip-inner {
max-width: 100%;
white-space: nowrap;
Expand Down Expand Up @@ -188,15 +196,14 @@ iframe {

button.btn {
white-space: inherit;
}

.btn.focus {
outline: none;
border: gainsboro 1px solid;
box-shadow: none;
}

.btn-outline-secondary, .btn-outline-secondary.focus, .btn-outline-secondary:focus {
border: none;
.btn-outline-secondary.active:focus,
.btn-outline-secondary:focus,
.btn-outline-secondary:active:focus {
outline: 0;
box-shadow: none;
}

Expand Down
32 changes: 17 additions & 15 deletions plugin-code/src/main/resources/template/macros/scenario.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,24 @@ limitations under the License.

<#macro stepHooks hooks>
<#list hooks as hook>
<div class="stepHook collapse">
<div class="row row_${hook.consolidatedStatusString} table-row-${hook.consolidatedStatusString}">
<div class="col-1"></div>
<div class="col-8 text-left">
<i>${hook.glueMethodName}</i>
</div>
<div class="col-2 text-left small">
<span class="nobr">${hook.result.returnDurationString()}</span>
</div>
<div class="col-1 text-right">
<@common.status status=hook.consolidatedStatusString/>
<#if hook.hasContent()>
<div class="stepHook collapse">
<div class="row row_${hook.consolidatedStatusString} table-row-${hook.consolidatedStatusString}">
<div class="col-1"></div>
<div class="col-8 text-left">
<i>${hook.glueMethodName}</i>
</div>
<div class="col-2 text-left small">
<span class="nobr">${hook.result.returnDurationString()}</span>
</div>
<div class="col-1 text-right">
<@common.status status=hook.consolidatedStatusString/>
</div>
<@scenario.errorMessage step=hook/>
<@scenario.output step=hook/>
<@scenario.attachments step=hook/>
</div>
<@scenario.errorMessage step=hook/>
<@scenario.output step=hook/>
<@scenario.attachments step=hook/>
</div>
</div>
</#if>
</#list>
</#macro>
Loading

0 comments on commit 1c2aaa1

Please sign in to comment.