From ab12cea1fa9a54d651f7bcc9fdea23f8d4b2d219 Mon Sep 17 00:00:00 2001
From: Benjamin Bischoff <5775857+bischoffdev@users.noreply.github.com>
Date: Mon, 7 Aug 2023 13:11:40 +0200
Subject: [PATCH] 3.3.0 (#317)
* version update
* re-introduced Maven skip option
* re-introduced Maven skip option
* removed Twitter link
* removed twitter
* click on bar charts work
* skipped state handling
* updated changelog for 3.3.0
---
CHANGELOG.md | 10 ++
core/pom.xml | 4 +-
engine/pom.xml | 4 +-
.../cluecumber/engine/json/pojo/Element.java | 2 +-
.../rendering/pages/pojos/ReportDetails.java | 12 +-
.../renderering/AllFeaturesPageRenderer.java | 8 +
.../renderering/AllStepsPageRenderer.java | 8 +
.../renderering/AllTagsPageRenderer.java | 8 +
.../main/resources/template/macros/page.ftl | 2 +-
.../main/resources/template/snippets/js.ftl | 97 +++++++-----
.../main/resources/template/step-summary.ftl | 9 +-
.../engine/json/pojo/ElementTest.java | 4 +-
examples/core-example/pom.xml | 2 +-
examples/maven-example/json/skip.json | 145 ++++++++++++++++++
examples/maven-example/pom.xml | 7 +-
maven/README.md | 3 +-
maven/pom.xml | 4 +-
.../cluecumber/maven/CluecumberMaven.java | 10 +-
pom.xml | 2 +-
19 files changed, 280 insertions(+), 61 deletions(-)
create mode 100644 examples/maven-example/json/skip.json
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 776222ac..c24269b8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
Back to [Readme](README.md).
+## [3.3.0] - 2023-08-07
+
+### Fixed
+* Scenarios having skipped steps after a passed step are now considered skipped (used to be passed) (#314)
+* `skip` parameter in Cluecumber Maven was not recognized anymore (#316)
+
+### Added
+* Charts in "All Tags", "All Features" and "All Steps" can now be clicked and redirect to the according detail page
+
## [3.2.2] - 2023-05-12
### Fixed
@@ -737,6 +746,7 @@ steps with status `pending` or `undefined` (default value is `false`) (#74)
Initial project version on GitHub and Maven Central.
+[3.3.0]: https://github.com/trivago/cluecumber-report-plugin/tree/3.3.0
[3.2.2]: https://github.com/trivago/cluecumber-report-plugin/tree/3.2.2
[3.2.1]: https://github.com/trivago/cluecumber-report-plugin/tree/3.2.1
[3.2.0]: https://github.com/trivago/cluecumber-report-plugin/tree/3.2.0
diff --git a/core/pom.xml b/core/pom.xml
index 894b859e..47006a71 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -6,13 +6,13 @@
4.0.0
cluecumber-core
- 3.2.2
+ 3.3.0
jar
cluecumber-parent
com.trivago.rta
- 3.2.2
+ 3.3.0
Cluecumber Core
diff --git a/engine/pom.xml b/engine/pom.xml
index 4a0dcd81..acf61ce3 100644
--- a/engine/pom.xml
+++ b/engine/pom.xml
@@ -8,11 +8,11 @@
cluecumber-parent
com.trivago.rta
- 3.2.2
+ 3.3.0
cluecumber-engine
- 3.2.2
+ 3.3.0
jar
Cluecumber Engine
diff --git a/engine/src/main/java/com/trivago/cluecumber/engine/json/pojo/Element.java b/engine/src/main/java/com/trivago/cluecumber/engine/json/pojo/Element.java
index e189f1ec..c19fa7b1 100644
--- a/engine/src/main/java/com/trivago/cluecumber/engine/json/pojo/Element.java
+++ b/engine/src/main/java/com/trivago/cluecumber/engine/json/pojo/Element.java
@@ -413,7 +413,7 @@ public Status getStatus() {
if (failOnPendingOrUndefined) {
return Status.FAILED;
}
- return Status.PASSED;
+ return Status.SKIPPED;
}
// If all steps are skipped return skipped (or failed if failOnPendingOrUndefined is true).
diff --git a/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/pojos/ReportDetails.java b/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/pojos/ReportDetails.java
index 58aa3f32..44127883 100644
--- a/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/pojos/ReportDetails.java
+++ b/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/pojos/ReportDetails.java
@@ -21,6 +21,8 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
/**
* Information about the report generation date and Cluecumber version.
@@ -28,7 +30,7 @@
public class ReportDetails {
private final String date;
private String chartJson;
-
+ private Map chartUrlLookup = new HashMap<>();
/**
* Constructor setting the generation date.
@@ -75,4 +77,12 @@ public String getGeneratorName() {
return String.format("%s version %s",
Settings.NAME, RenderingUtils.getPluginVersion());
}
+
+ public Map getChartUrlLookup() {
+ return chartUrlLookup;
+ }
+
+ public void setChartUrlLookup(Map chartUrlLookup) {
+ this.chartUrlLookup = chartUrlLookup;
+ }
}
diff --git a/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/renderering/AllFeaturesPageRenderer.java b/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/renderering/AllFeaturesPageRenderer.java
index eca22816..9f4d2103 100644
--- a/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/renderering/AllFeaturesPageRenderer.java
+++ b/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/renderering/AllFeaturesPageRenderer.java
@@ -31,6 +31,7 @@
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -87,9 +88,15 @@ private void addChartJsonToReportDetails(final AllFeaturesPageCollection allFeat
List passed = new ArrayList<>();
List failed = new ArrayList<>();
List skipped = new ArrayList<>();
+ Map urlLookup = new HashMap<>();
int maximumNumberOfRuns = 0;
for (Map.Entry entry : allFeaturesPageCollection.getFeatureResultCounts().entrySet()) {
+ urlLookup.put(
+ entry.getKey().getName(),
+ propertyManager.getGeneratedHtmlReportDirectory() + "/" +
+ Settings.PAGES_DIRECTORY + Settings.FEATURE_SCENARIOS_PAGE_FRAGMENT +
+ entry.getKey().getIndex() + Settings.HTML_FILE_EXTENSION);
ResultCount featureResultCount = entry.getValue();
passed.add((float) featureResultCount.getPassed());
failed.add((float) featureResultCount.getFailed());
@@ -117,6 +124,7 @@ private void addChartJsonToReportDetails(final AllFeaturesPageCollection allFeat
.build();
allFeaturesPageCollection.getReportDetails().setChartJson(convertChartToJson(chart));
+ allFeaturesPageCollection.getReportDetails().setChartUrlLookup(urlLookup);
}
}
diff --git a/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/renderering/AllStepsPageRenderer.java b/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/renderering/AllStepsPageRenderer.java
index e20277b3..6422d1df 100644
--- a/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/renderering/AllStepsPageRenderer.java
+++ b/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/renderering/AllStepsPageRenderer.java
@@ -30,6 +30,7 @@
import javax.inject.Inject;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -86,9 +87,15 @@ private void addChartJsonToReportDetails(final AllStepsPageCollection allTagsPag
List passed = new ArrayList<>();
List failed = new ArrayList<>();
List skipped = new ArrayList<>();
+ Map urlLookup = new HashMap<>();
int maximumNumberOfRuns = 0;
for (Map.Entry entry : allTagsPageCollection.getStepResultCounts().entrySet()) {
+ urlLookup.put(
+ entry.getKey().returnNameWithArgumentPlaceholders(),
+ propertyManager.getGeneratedHtmlReportDirectory() + "/" +
+ Settings.PAGES_DIRECTORY + Settings.STEP_SCENARIO_PAGE_FRAGMENT +
+ entry.getKey().getUrlFriendlyName() + Settings.HTML_FILE_EXTENSION);
ResultCount stepResultCount = entry.getValue();
passed.add((float) stepResultCount.getPassed());
failed.add((float) stepResultCount.getFailed());
@@ -117,5 +124,6 @@ private void addChartJsonToReportDetails(final AllStepsPageCollection allTagsPag
allTagsPageCollection.getReportDetails().setChartJson(convertChartToJson(chart));
+ allTagsPageCollection.getReportDetails().setChartUrlLookup(urlLookup);
}
}
diff --git a/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/renderering/AllTagsPageRenderer.java b/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/renderering/AllTagsPageRenderer.java
index 42d9ecc8..1dd7348d 100644
--- a/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/renderering/AllTagsPageRenderer.java
+++ b/engine/src/main/java/com/trivago/cluecumber/engine/rendering/pages/renderering/AllTagsPageRenderer.java
@@ -31,6 +31,7 @@
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -87,9 +88,15 @@ private void addChartJsonToReportDetails(final AllTagsPageCollection allTagsPage
List passed = new ArrayList<>();
List failed = new ArrayList<>();
List skipped = new ArrayList<>();
+ Map urlLookup = new HashMap<>();
int maximumNumberOfRuns = 0;
for (Map.Entry entry : allTagsPageCollection.getTagResultCounts().entrySet()) {
+ urlLookup.put(
+ entry.getKey().getName(),
+ propertyManager.getGeneratedHtmlReportDirectory() + "/" +
+ Settings.PAGES_DIRECTORY + Settings.TAG_SCENARIO_PAGE_FRAGMENT +
+ entry.getKey().getUrlFriendlyName() + Settings.HTML_FILE_EXTENSION);
ResultCount tagResultCount = entry.getValue();
passed.add((float) tagResultCount.getPassed());
failed.add((float) tagResultCount.getFailed());
@@ -116,6 +123,7 @@ private void addChartJsonToReportDetails(final AllTagsPageCollection allTagsPage
.build();
allTagsPageCollection.getReportDetails().setChartJson(convertChartToJson(chart));
+ allTagsPageCollection.getReportDetails().setChartUrlLookup(urlLookup);
}
}
diff --git a/engine/src/main/resources/template/macros/page.ftl b/engine/src/main/resources/template/macros/page.ftl
index 2d7b4477..00e17447 100644
--- a/engine/src/main/resources/template/macros/page.ftl
+++ b/engine/src/main/resources/template/macros/page.ftl
@@ -89,4 +89,4 @@ limitations under the License.
-#macro>
+#macro>
\ No newline at end of file
diff --git a/engine/src/main/resources/template/snippets/js.ftl b/engine/src/main/resources/template/snippets/js.ftl
index 5e9a676a..fc525c97 100644
--- a/engine/src/main/resources/template/snippets/js.ftl
+++ b/engine/src/main/resources/template/snippets/js.ftl
@@ -48,51 +48,68 @@ limitations under the License.
// Chart
<#if (reportDetails.chartJson?has_content)>
- var canvas = document.getElementById('chart-area');
- var ctx = canvas.getContext("2d");
- var chart = new Chart(ctx, ${reportDetails.chartJson});
-
- var original;
- if (chart.config.type === "pie") {
- original = Chart.defaults.pie.legend.onClick;
- } else {
- original = Chart.defaults.global.legend.onClick;
- }
-
- chart.options.onClick = function (evt, elements) {
- if (chart.config.type !== "pie") return;
- chartArea = elements[0];
- if (chartArea === undefined) return;
- chartArea.hidden = !chartArea.hidden;
- chart.update();
- toggleVisibilityByStatus(chartArea._model.label, !chartArea.hidden)
- };
-
- chart.options.legend.onClick = function (evt, label) {
- original.call(this, evt, label);
- toggleVisibilityByStatus(label.text, label.hidden);
- };
+ var canvas = document.getElementById('chart-area');
+ var ctx = canvas.getContext("2d");
+ var chart = new Chart(ctx, ${reportDetails.chartJson});
+
+ var original;
+ if (chart.config.type === "pie") {
+ original = Chart.defaults.pie.legend.onClick;
+ chart.options.onClick = function (evt, elements) {
+ chartArea = elements[0];
+ if (chartArea === undefined) return;
+ chartArea.hidden = !chartArea.hidden;
+ chart.update();
+ toggleVisibilityByStatus(chartArea._model.label, !chartArea.hidden)
+ };
+ } else if (chart.config.type === "bar") {
+ <#if (reportDetails.chartUrlLookup?has_content)>
+ console.log("LOOKUP: " + ${reportDetails.chartUrlLookup?size})
+ const chartUrls = {
+ <#list reportDetails.chartUrlLookup as stepName, urlFriendlyStepName>
+ "${stepName?js_string}": "${urlFriendlyStepName}",
+ #list>
+ };
+ canvas.onclick = function (evt) {
+ const activePoints = chart.getElementsAtEvent(evt);
+ if (activePoints.length <= 0) return;
+ const clickedElementindex = activePoints[0]["_index"];
+ const label = chart.data.labels[clickedElementindex];
+ if (label == null) return;
+ urlSnippet = chartUrls[label];
+ //const url = document.evaluate("//a[text()='" + label + "']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
+ console.log(urlSnippet);
+ if (urlSnippet == null) return;
+ window.location.href = urlSnippet;
+ }
+ #if>
+ original = Chart.defaults.global.legend.onClick;
+ }
- function toggleVisibilityByStatus(statusText, show) {
- var card = $("#card_" + statusText);
- if (card !== undefined) {
- if (show) {
- card.show();
- } else {
- card.hide();
+ chart.options.legend.onClick = function (evt, label) {
+ original.call(this, evt, label);
+ toggleVisibilityByStatus(label.text, label.hidden);
+ };
+
+ function toggleVisibilityByStatus(statusText, show) {
+ var card = $("#card_" + statusText);
+ if (card !== undefined) {
+ if (show) {
+ card.show();
+ } else {
+ card.hide();
+ }
}
- }
- var row = $(".table-row-" + statusText);
- if (row !== undefined) {
- if (show) {
- row.show();
- } else {
- row.hide();
+ var row = $(".table-row-" + statusText);
+ if (row !== undefined) {
+ if (show) {
+ row.show();
+ } else {
+ row.hide();
+ }
}
}
- }
-
#if>
if (${expandBeforeAfterHooks?c}) {
diff --git a/engine/src/main/resources/template/step-summary.ftl b/engine/src/main/resources/template/step-summary.ftl
index 543e0c78..2f7739f1 100644
--- a/engine/src/main/resources/template/step-summary.ftl
+++ b/engine/src/main/resources/template/step-summary.ftl
@@ -100,4 +100,11 @@ preheadlineLink="">
@page.card>
-@page.page>
+<#-- -->
+@page.page>
\ No newline at end of file
diff --git a/engine/src/test/java/com/trivago/cluecumber/engine/json/pojo/ElementTest.java b/engine/src/test/java/com/trivago/cluecumber/engine/json/pojo/ElementTest.java
index 789ba2bd..eb324e37 100644
--- a/engine/src/test/java/com/trivago/cluecumber/engine/json/pojo/ElementTest.java
+++ b/engine/src/test/java/com/trivago/cluecumber/engine/json/pojo/ElementTest.java
@@ -44,7 +44,7 @@ public void getPassedStatusTest() {
}
@Test
- public void passedStatusOnPassedAndSkippedStepsTest() {
+ public void skippedStatusOnPassedAndSkippedStepsTest() {
List steps = new ArrayList<>();
Step step = new Step();
Result result = new Result();
@@ -60,7 +60,7 @@ public void passedStatusOnPassedAndSkippedStepsTest() {
element.setSteps(steps);
Status status = element.getStatus();
- assertEquals(status, Status.PASSED);
+ assertEquals(status, Status.SKIPPED);
}
@Test
diff --git a/examples/core-example/pom.xml b/examples/core-example/pom.xml
index e89a9385..f5486b08 100644
--- a/examples/core-example/pom.xml
+++ b/examples/core-example/pom.xml
@@ -6,7 +6,7 @@
blog.softwaretester
core-example
- 3.2.2
+ 3.3.0
pom
diff --git a/examples/maven-example/json/skip.json b/examples/maven-example/json/skip.json
new file mode 100644
index 00000000..83740e2e
--- /dev/null
+++ b/examples/maven-example/json/skip.json
@@ -0,0 +1,145 @@
+[
+ {
+ "line": 2,
+ "elements": [
+ {
+ "start_timestamp": "2023-08-02T13:45:04.883Z",
+ "before": [
+ {
+ "result": {
+ "duration": 5752270400,
+ "status": "passed"
+ },
+ "match": {
+ "location": "somelocation.beforeCucumberScenario()"
+ }
+ }
+ ],
+ "line": 5,
+ "name": "Step ahead and backward by pressing \">\" and \"<\"",
+ "description": "",
+ "id": "someid-\">\"-and-\"<\"",
+ "after": [
+ {
+ "result": {
+ "duration": 851622500,
+ "status": "passed"
+ },
+ "match": {
+ "location": "somelocation.afterCucumberScenario(io.cucumber.java.Scenario)"
+ }
+ }
+ ],
+ "type": "scenario",
+ "keyword": "Scenario",
+ "steps": [
+ {
+ "result": {
+ "duration": 7109716400,
+ "status": "passed"
+ },
+ "line": 6,
+ "name": "I navigate to today",
+ "match": {
+ "location": "somelocation.loginAndNavigateTo(java.lang.String,java.lang.String)"
+ },
+ "keyword": "Given "
+ },
+ {
+ "result": {
+ "error_message": "Some skipped message",
+ "duration": 244045200,
+ "status": "skipped"
+ },
+ "line": 7,
+ "name": "I step ahead by pressing >",
+ "match": {
+ "arguments": [
+ {
+ "val": ">",
+ "offset": 25
+ }
+ ],
+ "location": "somelocation.stepAhead(java.lang.String)"
+ },
+ "keyword": "When "
+ },
+ {
+ "result": {
+ "status": "skipped"
+ },
+ "line": 8,
+ "name": "the date should be updated",
+ "match": {
+ "location": "somelocation.validate(java.lang.String)"
+ },
+ "keyword": "Then "
+ },
+ {
+ "result": {
+ "status": "skipped"
+ },
+ "line": 9,
+ "name": "I step back by pressing <",
+ "match": {
+ "location": "somelocation.stepBack(java.lang.String)"
+ },
+ "keyword": "When "
+ },
+ {
+ "result": {
+ "status": "skipped"
+ },
+ "line": 10,
+ "name": "the date should be updated",
+ "match": {
+ "location": "somelocation.validate(java.lang.String)"
+ },
+ "keyword": "Then "
+ },
+ {
+ "result": {
+ "status": "skipped"
+ },
+ "line": 11,
+ "name": "I step back again by pressing <",
+ "match": {
+ "arguments": [
+ {
+ "val": "<",
+ "offset": 25
+ }
+ ],
+ "location": "somelocation.stepOneDayAheadByPressing(java.lang.String)"
+ },
+ "keyword": "When "
+ },
+ {
+ "result": {
+ "status": "skipped"
+ },
+ "line": 12,
+ "name": "the date should be updated",
+ "match": {
+ "location": "somelocation.validate(java.lang.String)"
+ },
+ "keyword": "Then "
+ }
+ ],
+ "tags": [
+ {
+ "name": "@tag1"
+ },
+ {
+ "name": "@tag2"
+ }
+ ]
+ }
+ ],
+ "name": "Calendar scenarios",
+ "description": "",
+ "id": "calendar-scenarios",
+ "keyword": "Feature",
+ "uri": "classpath:Calendar.feature"
+ }
+]
\ No newline at end of file
diff --git a/examples/maven-example/pom.xml b/examples/maven-example/pom.xml
index eb6a12e2..09645567 100644
--- a/examples/maven-example/pom.xml
+++ b/examples/maven-example/pom.xml
@@ -6,7 +6,7 @@
blog.softwaretester
maven-example
- 3.2.2
+ 3.3.0
pom
@@ -37,7 +37,7 @@
- ${cucumber.report.json.location}
+ ${cucumber.report.json.location}/skip.json
${generated.report.location}
@@ -87,12 +87,11 @@
-
+
https://www.softwaretester.blog
- https://twitter.com/BischoffDev
diff --git a/maven/README.md b/maven/README.md
index 624ef888..6d809651 100644
--- a/maven/README.md
+++ b/maven/README.md
@@ -210,7 +210,6 @@ this is possible via the `customNavigationLinks` property.
https://www.softwaretester.blog
- https://twitter.com/BischoffDev
...
@@ -223,7 +222,7 @@ these are replaces with spaces for the link name:
## Skip Report Generation
-The `skip` property is used to skip the report generation. The default value is `false`
+The `skip` property is used to skip the report generation completely. The default value is `false`
```xml
diff --git a/maven/pom.xml b/maven/pom.xml
index 8671313a..4f846545 100644
--- a/maven/pom.xml
+++ b/maven/pom.xml
@@ -7,12 +7,12 @@
cluecumber-maven
maven-plugin
- 3.2.2
+ 3.3.0
cluecumber-parent
com.trivago.rta
- 3.2.2
+ 3.3.0
Cluecumber Maven
diff --git a/maven/src/main/java/com/trivago/cluecumber/maven/CluecumberMaven.java b/maven/src/main/java/com/trivago/cluecumber/maven/CluecumberMaven.java
index 00655223..b6026b9c 100644
--- a/maven/src/main/java/com/trivago/cluecumber/maven/CluecumberMaven.java
+++ b/maven/src/main/java/com/trivago/cluecumber/maven/CluecumberMaven.java
@@ -147,11 +147,19 @@ public final class CluecumberMaven extends AbstractMojo {
* Optional log level to control what information is logged in the console.
* Allowed values: default, compact, minimal, off
*/
- @Parameter(property = "parallel.logLevel", defaultValue = "default")
+ @Parameter(property = "reporting.logLevel", defaultValue = "default")
String logLevel;
+ @Parameter(property = "reporting.skip", defaultValue = "false")
+ private boolean skip;
+
@Override
public void execute() throws MojoExecutionException {
+ if (skip) {
+ System.out.println("Report generation was skipped deliberately.");
+ return;
+ }
+
try {
new CluecumberCore.Builder()
.setCustomStatusColorSkipped(customStatusColorSkipped)
diff --git a/pom.xml b/pom.xml
index 991f408f..d4e89653 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
com.trivago.rta
cluecumber-parent
- 3.2.2
+ 3.3.0
pom
Cluecumber Parent