Skip to content

Commit

Permalink
3.10.0 (#365)
Browse files Browse the repository at this point in the history
* version bump, changelog, dagger update

* removed console logs

* started refactoring status consolidation

* 3.10.0
  • Loading branch information
bischoffdev authored Jan 6, 2025
1 parent 685d101 commit 05b9682
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 84 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

Back to [Readme](README.md).

## [3.10.0] - 2025-01-06

### Added

* Step and scenario results are now cached to speed up report generation

### Fixed

* Unnecessary console logs for dark mode feature (#363)
* Step was reported as passed when a step hook failed (#364)
* Include Hooks in All Steps report to track failures related to Hooks (#364)
* Fixed absolute path to the finished report in the console log

### Changed

* Strict adherence to the official cucumber guidelines for scenario states
* Google Dagger updated to `2.54`
* Freemarker updated to `2.3.33`
* Javadoc updated to `3.11.2`
* JUnit Jupiter updated to `5.11.4`
* Mockito updated to `5.15.2`

## [3.9.0] - 2024-11-05

### Fixed
Expand Down Expand Up @@ -940,6 +962,8 @@ the core component is now the reporting engine that is the base for other forms

Initial project version on GitHub and Maven Central.

[3.10.0]: https://github.com/trivago/cluecumber-report-plugin/tree/v3.10.0

[3.9.0]: https://github.com/trivago/cluecumber-report-plugin/tree/v3.9.0

[3.8.2]: https://github.com/trivago/cluecumber-report-plugin/tree/v3.8.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ public Builder setCustomStatusColorSkipped(final String customStatusColorSkipped
}

/**
* Whether to expand sub sections or not.
* Whether to expand subsections or not.
*
* @param expandSubSections If true, sub sections will be expanded.
* @param expandSubSections If true, subsections will be expanded.
* @return The {@link Builder}.
*/
public Builder setExpandSubSections(final boolean expandSubSections) {
Expand All @@ -237,7 +237,7 @@ public Builder setExpandAttachments(final boolean expandAttachments) {
}

/**
* Whether to expand stepoutputs or not.
* Whether to expand step outputs or not.
*
* @param expandOutputs If true, outputs will be expanded.
* @return The {@link Builder}.
Expand Down Expand Up @@ -325,7 +325,7 @@ public Builder setStartPage(final Settings.StartPage startPage) {
}

/**
* Set a custom page tite for the report.
* Set a custom page title for the report.
*
* @param customPageTitle The custom page title.
* @return The {@link Builder}.
Expand Down
4 changes: 2 additions & 2 deletions engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tinylog-impl.version>2.8.0-M1</tinylog-impl.version>
<freemarker.version>2.3.33</freemarker.version>
<freemarker.version>2.3.34</freemarker.version>
<gson-fire.version>1.9.0</gson-fire.version>
<gson.version>2.11.0</gson.version>
<dagger.version>2.52</dagger.version>
<dagger.version>2.54</dagger.version>
<property-aggregator.version>1.5.0</property-aggregator.version>
<properties-maven-plugin.version>1.1.0</properties-maven-plugin.version>
<openpojo.version>0.9.1</openpojo.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.trivago.cluecumber.engine.rendering.pages.renderering.RenderingUtils;

import javax.inject.Inject;
import java.io.File;
import java.nio.file.Path;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -138,9 +139,11 @@ public void build(
elementMultipleRunsPreProcessor.addMultipleRunsInformationToScenarios(allScenariosPageCollection.getReports());
}
reportGenerator.generateReport(allScenariosPageCollection);
String absoluteReportPath = new File(
propertyManager.getGeneratedHtmlReportDirectory(),
Settings.START_PAGE + Settings.HTML_FILE_EXTENSION).getAbsolutePath();
logger.info(
"=> Cluecumber Report: file:///" + propertyManager.getGeneratedHtmlReportDirectory() + "/" +
Settings.START_PAGE + Settings.HTML_FILE_EXTENSION,
"=> Cluecumber Report: file:///" + absoluteReportPath,
DEFAULT,
COMPACT,
MINIMAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,26 @@
import javax.inject.Singleton;

/**
* This stores the colors and type of a report chart.
* This stores the colors and type of report chart.
*/
@Singleton
public class ChartConfiguration {

private final PropertyManager propertyManager;
private String passedColorRgbaString;
private String failedColorRgbaString;
private String skippedColorRgbaString;
private final String passedColorRgbaString;
private final String failedColorRgbaString;
private final String skippedColorRgbaString;

/**
* Constructor for dependency injection.
*
* @param propertyManager The {@link PropertyManager} instance.
*/
@Inject
public ChartConfiguration(final PropertyManager propertyManager) {
this.propertyManager = propertyManager;
public ChartConfiguration(
final PropertyManager propertyManager) {
this.failedColorRgbaString = getRgbaColorStringFromHex(propertyManager.getCustomStatusColorFailed());
this.passedColorRgbaString = getRgbaColorStringFromHex(propertyManager.getCustomStatusColorPassed());
this.skippedColorRgbaString = getRgbaColorStringFromHex(propertyManager.getCustomStatusColorSkipped());
}

/**
Expand All @@ -66,9 +68,6 @@ public String getColorRgbaStringByStatus(final Status status) {
* @return The RGBA color.
*/
public String getPassedColorRgbaString() {
if (passedColorRgbaString == null) {
passedColorRgbaString = getRgbaColorStringFromHex(propertyManager.getCustomStatusColorPassed());
}
return passedColorRgbaString;
}

Expand All @@ -78,9 +77,6 @@ public String getPassedColorRgbaString() {
* @return The RGBA color.
*/
public String getFailedColorRgbaString() {
if (failedColorRgbaString == null) {
failedColorRgbaString = getRgbaColorStringFromHex(propertyManager.getCustomStatusColorFailed());
}
return failedColorRgbaString;
}

Expand All @@ -90,9 +86,6 @@ public String getFailedColorRgbaString() {
* @return The RGBA color.
*/
public String getSkippedColorRgbaString() {
if (skippedColorRgbaString == null) {
skippedColorRgbaString = getRgbaColorStringFromHex(propertyManager.getCustomStatusColorSkipped());
}
return skippedColorRgbaString;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ public Settings() {
* The first part of the name of scenario detail pages.
*/
public static final String SCENARIO_DETAIL_PAGE_FRAGMENT = "/" + SCENARIO_DETAIL_PAGE_PATH + "/scenario_";
/**
* The folder of the scenario rerun pages.
*/
public final static String SCENARIO_RERUN_PAGE_PATH = "scenario-detail";
/**
* The first part of the name of scenario rerun pages.
*/
public static final String SCENARIO_RERUN_PAGE_FRAGMENT = "/" + SCENARIO_RERUN_PAGE_PATH + "/scenario_";
/**
* The name of the tag summary page.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,14 @@
package com.trivago.cluecumber.engine.constants;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

/**
* Enum to manage all states for steps and scenarios.
*/
public enum Status {
/**
* Passed status.
*/
PASSED("passed"),
/**
* Failed status.
*/
Expand All @@ -61,7 +58,15 @@ public enum Status {
/**
* Ambiguous status.
*/
AMBIGUOUS("ambiguous");
AMBIGUOUS("ambiguous"),
/**
* Passed status.
*/
PASSED("passed"),
/**
* Ambiguous unused.
*/
UNUSED("unused");

/**
* The three basic states: passed, failed and skipped.
Expand Down Expand Up @@ -102,15 +107,30 @@ public Status basicStatus() {

/**
* Return the highest status from the given list of states.
*
* @param allStates The list of states.
* @return The status string.
* @return The highest status.
*/
public static Status getHighestBasicState(Set<Status> allStates) {
return BASIC_STATES.stream().filter(
basicState -> allStates.stream().anyMatch(allState -> allState.basicStatus() == basicState)
).findFirst().orElse(FAILED);
}

/**
* Get the highest state from all states.
*
* @param allStates The list of states.
* @return The highest status.
*/
public static Status getHighestState(Set<Status> allStates) {
return Arrays.stream(values())
.filter(state -> allStates.stream()
.anyMatch(allState -> allState == state))
.findFirst()
.orElse(FAILED);
}

/**
* Return the status string from this enum.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class Element {
private transient int featureIndex = 0;
private transient int scenarioIndex = 0;
private transient boolean failOnPendingOrUndefined = false;
private Status status;

/**
* Default constructor.
Expand Down Expand Up @@ -369,22 +370,25 @@ public boolean isSkipped() {
* @return The overall status.
*/
public Status getStatus() {
if (status != null) {
return status;
}

Set<Status> allStates = before.stream().map(ResultMatch::getStatus).collect(Collectors.toSet());
backgroundSteps.stream().map(ResultMatch::getStatus).forEach(allStates::add);
steps.forEach(step -> step.getBefore().forEach(result -> allStates.add(result.getStatus())));
steps.stream().map(ResultMatch::getStatus).forEach(allStates::add);
steps.forEach(step -> step.getAfter().forEach(result -> allStates.add(result.getStatus())));
backgroundSteps.stream().map(Step::getStatus).forEach(allStates::add);
steps.stream().map(Step::getStatus).forEach(allStates::add);
after.stream().map(ResultMatch::getStatus).forEach(allStates::add);

if (allStates.isEmpty()) {
return Status.SKIPPED;
}

if (failOnPendingOrUndefined && (allStates.contains(Status.PENDING) || allStates.contains(Status.UNDEFINED))) {
return Status.FAILED;
status = Status.SKIPPED;
} else if (failOnPendingOrUndefined && (allStates.contains(Status.PENDING) ||
allStates.contains(Status.UNDEFINED))) {
status = Status.FAILED;
} else {
status = Status.getHighestBasicState(allStates);
}

return Status.getHighestBasicState(allStates);
return status;
}

/**
Expand Down Expand Up @@ -541,9 +545,9 @@ private int getNumberOfStepsWithStatus(final Status status) {
*/
public long getTotalDuration() {
return before.stream().mapToLong(beforeStep -> beforeStep.getResult().getDuration()).sum() +
backgroundSteps.stream().mapToLong(Step::getTotalDuration).sum() +
steps.stream().mapToLong(Step::getTotalDuration).sum() +
after.stream().mapToLong(afterStep -> afterStep.getResult().getDuration()).sum();
backgroundSteps.stream().mapToLong(Step::getTotalDuration).sum() +
steps.stream().mapToLong(Step::getTotalDuration).sum() +
after.stream().mapToLong(afterStep -> afterStep.getResult().getDuration()).sum();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
package com.trivago.cluecumber.engine.json.pojo;

import com.google.gson.annotations.SerializedName;
import com.trivago.cluecumber.engine.constants.Status;
import com.trivago.cluecumber.engine.rendering.pages.renderering.RenderingUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -44,6 +41,7 @@ public class Step extends ResultMatch {
private boolean hasSubSections = false;

private static final Map<String, String> stepMatchToNameWithArgumentPlaceholders = new HashMap<>();
private Status status;

/**
* Default constructor.
Expand All @@ -52,6 +50,28 @@ public Step() {
// Default constructor
}

/**
* Overwritten getStatus method so that hook statuses are considered as well
*
* @return The highest status of the step and its hooks.
*/
public Status getStatus() {
if (status != null) {
return status;
}

Set<Status> allStatuses = new HashSet<>();
allStatuses.add(super.getStatus());
before.stream()
.map(beforeStep -> Status.fromString(beforeStep.getResult().getStatus()))
.forEach(allStatuses::add);
after.stream()
.map(afterStep -> Status.fromString(afterStep.getResult().getStatus()))
.forEach(allStatuses::add);
status = Status.getHighestState(allStatuses);
return status;
}

/**
* Check if there are before or after step hooks with content.
*
Expand Down
4 changes: 3 additions & 1 deletion engine/src/main/resources/template/macros/navigation.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ limitations under the License.

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<#--noinspection FtlReferencesInspection-->
<#list navigationLinks as link>
<li class="nav-item">
<#assign highlightClass="">
Expand Down Expand Up @@ -61,7 +62,8 @@ limitations under the License.
</li>
</#list>
</ul>
<button id="dark-light-mode-switch" class="btn btn-secondary btn-sm">Dark Mode</button>
<button id="dark-light-mode-switch" class="btn btn-secondary btn-sm text-sm-center">Dark Mode</button>
<#--noinspection FtlReferencesInspection-->
<span class="text-light">${reportDetails.date}</span>
</div>
</nav>
Expand Down
5 changes: 0 additions & 5 deletions engine/src/main/resources/template/snippets/js.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,9 @@ limitations under the License.
function updateDarkLightModeButton(isDarkMode) {
const button = document.getElementById('dark-light-mode-switch');
console.log("BUTTON: " + button);
console.log("isDarkMode: " + isDarkMode);
console.log("button.textContent: " + button.textContent);
button.textContent = isDarkMode ? 'Light Mode' : 'Dark Mode';
}
console.log("The button is " + document.getElementById('dark-light-mode-switch'))
function resizeIframe(iframe) {
setInterval(function () {
try {
Expand Down
Loading

0 comments on commit 05b9682

Please sign in to comment.