Skip to content

Commit

Permalink
3.1.0 (#305)
Browse files Browse the repository at this point in the history
* started tree view page

* tree formatting, feature display

* tree view

* first tree iteration

* tree view

* design changes
  • Loading branch information
bischoffdev authored Jan 17, 2023
1 parent 0249a1d commit fa54afe
Show file tree
Hide file tree
Showing 39 changed files with 319 additions and 68 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

Back to [Readme](README.md).

## [3.1.0] - 2023-01-17

### Added
* Added new test overview tree view page

### Fixed
* Aligned counts and use of plurals in headlines
* Fixed misaligned numbers in tag, step and feature overview page tables
* Various small design adjustments and fixes

### Changed
* Clearer custom parameters box
* Tags are now displayed as buttons

## [3.0.2] - 2022-12-22

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

Initial project version on GitHub and Maven Central.

[3.1.0]: https://github.com/trivago/cluecumber-report-plugin/tree/3.1.0
[3.0.2]: https://github.com/trivago/cluecumber-report-plugin/tree/3.0.2
[3.0.1]: https://github.com/trivago/cluecumber-report-plugin/tree/3.0.1
[3.0.0]: https://github.com/trivago/cluecumber-report-plugin/tree/3.0.0
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ It is available in [Maven central](https://search.maven.org/#search%7Cgav%7C1%7C
* __Scenarios by Tag__: all scenarios including a specific tag
* __Scenarios by Feature__: all scenarios belonging to a specific feature
* __Scenario by Step__: all scenarios that include a specific step
* __Tree View__: all features and scenarios in a tree for an easy overview of the test suite

## Star History

Expand Down
3 changes: 2 additions & 1 deletion core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>com.trivago.rta</groupId>
<artifactId>cluecumber-core</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
</dependency>
```

Expand Down Expand Up @@ -271,6 +271,7 @@ This can be customized with one of the following values:
* `PluginSettings.StartPage.ALL_TAGS` (tag overview page)
* `PluginSettings.StartPage.ALL_STEPS` (step overview page)
* `PluginSettings.StartPage.ALL_FEATURES` (feature overview page)
* `PluginSettings.StartPage.TREE_VIEW` (tree view of features and scenarios)

## Defining a custom report title

Expand Down
4 changes: 2 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>cluecumber-core</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<packaging>jar</packaging>

<parent>
<artifactId>cluecumber-parent</artifactId>
<groupId>com.trivago.rta</groupId>
<version>3.0.2</version>
<version>3.1.0</version>
</parent>

<name>Cluecumber Core</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void generateReports(final String jsonDirectory, final String reportDirec
}

public static class Builder {
public LinkedHashMap<String, String> customViews;
protected String customCssFile;
protected LinkedHashMap<String, String> customNavigationLinks;
protected String customPageTitle;
Expand Down
4 changes: 2 additions & 2 deletions engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<parent>
<artifactId>cluecumber-parent</artifactId>
<groupId>com.trivago.rta</groupId>
<version>3.0.2</version>
<version>3.1.0</version>
</parent>

<artifactId>cluecumber-engine</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<packaging>jar</packaging>

<name>Cluecumber Engine</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Navigation {
new Link("scenario_sequence", "pages/scenario-sequence.html", LinkType.INTERNAL),
new Link("tag_summary", "pages/tag-summary.html", LinkType.INTERNAL),
new Link("step_summary", "pages/step-summary.html", LinkType.INTERNAL),
new Link("feature_summary", "pages/feature-summary.html", LinkType.INTERNAL)
new Link("feature_summary", "pages/feature-summary.html", LinkType.INTERNAL),
new Link("tree_view", "pages/tree-view.html", LinkType.INTERNAL)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public enum StartPage {
SCENARIO_SEQUENCE(SCENARIO_SEQUENCE_PAGE_PATH),
ALL_TAGS(TAG_SUMMARY_PAGE_PATH),
ALL_STEPS(STEP_SUMMARY_PAGE_PATH),
ALL_FEATURES(FEATURE_SUMMARY_PAGE_PATH);
ALL_FEATURES(FEATURE_SUMMARY_PAGE_PATH),
TREE_VIEW(TREE_VIEW_PAGE_PATH);

private final String pageName;

Expand Down Expand Up @@ -71,6 +72,7 @@ public enum CustomParamDisplayMode {
public final static String FEATURE_SUMMARY_PAGE_PATH = "feature-summary";
public static final String FEATURE_SCENARIOS_PAGE_PATH = "feature-scenarios";
public static final String FEATURE_SCENARIOS_PAGE_FRAGMENT = "/" + FEATURE_SCENARIOS_PAGE_PATH + "/feature_";
public static final String TREE_VIEW_PAGE_PATH = "tree-view";

PluginSettings() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Report implements Cloneable {
private int line;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.trivago.cluecumber.engine.rendering.pages.pojos;

import java.util.List;
import java.util.Objects;

public class Feature {
Expand All @@ -24,6 +25,7 @@ public class Feature {
private final int index;
private final String uri;


public Feature(final String name, final String description, final String uri, final int index) {
this.name = name;
this.description = description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ private void calculateFeatureResultCounts(final List<Report> reports) {
resultCounts = new HashMap<>();
totalNumberOfScenarios = 0;
reports.forEach(report -> {
Feature feature = new Feature(
report.getName(), report.getDescription(), report.getUri(), report.getFeatureIndex()
);
Feature feature = new Feature(report.getName(), report.getDescription(), report.getUri(), report.getFeatureIndex());
ResultCount featureResultCount = this.resultCounts.getOrDefault(feature, new ResultCount());
totalNumberOfScenarios += report.getElements().size();
report.getElements().forEach(element -> updateResultCount(featureResultCount, element.getStatus()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
public class AllScenariosPageCollection extends PageCollection implements Visitable {
Expand All @@ -48,6 +50,14 @@ public List<Report> getReports() {
return reports;
}

public List<Element> getElementsByFeatureIndex(final int featureIndex){
return getReports().stream()
.filter(report -> report.getFeatureIndex() == featureIndex)
.flatMap(report -> report.getElements().stream())
.sorted(Comparator.comparing(Element::getName))
.collect(Collectors.toList());
}

public void clearReports() {
reports = new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2019 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.trivago.cluecumber.engine.rendering.pages.pojos.pagecollections;

import com.trivago.cluecumber.engine.json.pojo.Element;
import com.trivago.cluecumber.engine.rendering.pages.pojos.Feature;

import java.util.List;
import java.util.Map;

public class TreeViewPageCollection extends PageCollection {
private final Map<Feature, List<Element>> elements;

public TreeViewPageCollection(final Map<Feature, List<Element>> elements, final String pageTitle) {
super(pageTitle);
this.elements = elements;
}

public Map<Feature, List<Element>> getElements() {
return elements;
}

public int getNumberOfFeatures() {
return elements.size();
}

public int getNumberOfScenarios() {
return elements.values().stream().mapToInt(List::size).sum();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2019 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.trivago.cluecumber.engine.rendering.pages.renderering;

import com.trivago.cluecumber.engine.exceptions.CluecumberException;
import com.trivago.cluecumber.engine.json.pojo.Element;
import com.trivago.cluecumber.engine.properties.PropertyManager;
import com.trivago.cluecumber.engine.rendering.pages.pojos.Feature;
import com.trivago.cluecumber.engine.rendering.pages.pojos.pagecollections.AllFeaturesPageCollection;
import com.trivago.cluecumber.engine.rendering.pages.pojos.pagecollections.AllScenariosPageCollection;
import com.trivago.cluecumber.engine.rendering.pages.pojos.pagecollections.TreeViewPageCollection;
import freemarker.template.Template;

import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

@Singleton
public class TreeViewPageRenderer extends PageRenderer {

private final PropertyManager propertyManager;

@Inject
public TreeViewPageRenderer(
final PropertyManager propertyManager
) {
this.propertyManager = propertyManager;
}

public String getRenderedContent(
final AllFeaturesPageCollection allFeaturesPageCollection,
final AllScenariosPageCollection allScenariosPageCollection,
final Template template)
throws CluecumberException {

Map<Feature, List<Element>> scenariosPerFeatures = new LinkedHashMap<>();
Set<Feature> features = allFeaturesPageCollection.getFeatures()
.stream().sorted(Comparator.comparing(Feature::getName))
.collect(Collectors.toCollection(LinkedHashSet::new));
for (Feature feature : features) {
scenariosPerFeatures.put(feature, allScenariosPageCollection.getElementsByFeatureIndex(feature.getIndex()));
}

return processedContent(
template,
new TreeViewPageCollection(scenariosPerFeatures, allFeaturesPageCollection.getPageTitle()),
propertyManager.getNavigationLinks()
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class TemplateEngine {
private final TemplateConfiguration templateConfiguration;

public enum Template {
TREE_VIEW("tree-view"),
ALL_FEATURES("feature-summary"),
ALL_SCENARIOS("scenario-summary"),
SCENARIO_SEQUENCE("scenario-sequence"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import com.trivago.cluecumber.engine.rendering.pages.pojos.pagecollections.AllScenariosPageCollection;
import com.trivago.cluecumber.engine.rendering.pages.renderering.AllFeaturesPageRenderer;
import com.trivago.cluecumber.engine.rendering.pages.renderering.AllScenariosPageRenderer;
import com.trivago.cluecumber.engine.rendering.pages.renderering.TreeViewPageRenderer;
import com.trivago.cluecumber.engine.rendering.pages.templates.TemplateEngine;

import javax.inject.Inject;
import javax.inject.Singleton;

import static com.trivago.cluecumber.engine.rendering.pages.templates.TemplateEngine.Template.ALL_FEATURES;
import static com.trivago.cluecumber.engine.rendering.pages.templates.TemplateEngine.Template.ALL_SCENARIOS;
import static com.trivago.cluecumber.engine.rendering.pages.templates.TemplateEngine.Template.TREE_VIEW;

@Singleton
public class FeatureVisitor implements PageVisitor {
Expand All @@ -25,20 +27,23 @@ public class FeatureVisitor implements PageVisitor {
private final PropertyManager propertyManager;
private final AllFeaturesPageRenderer allFeaturesPageRenderer;
private final AllScenariosPageRenderer allScenariosPageRenderer;
private final TreeViewPageRenderer treeViewPageRenderer;

@Inject
public FeatureVisitor(
final FileIO fileIO,
final TemplateEngine templateEngine,
final PropertyManager propertyManager,
final AllFeaturesPageRenderer allFeaturesPageRenderer,
final AllScenariosPageRenderer allScenariosPageRenderer
final AllScenariosPageRenderer allScenariosPageRenderer,
final TreeViewPageRenderer treeViewPageRenderer
) {
this.fileIO = fileIO;
this.templateEngine = templateEngine;
this.propertyManager = propertyManager;
this.allFeaturesPageRenderer = allFeaturesPageRenderer;
this.allScenariosPageRenderer = allScenariosPageRenderer;
this.treeViewPageRenderer = treeViewPageRenderer;
}

@Override
Expand All @@ -65,5 +70,14 @@ public void visit(final AllScenariosPageCollection allScenariosPageCollection) t
PluginSettings.PAGES_DIRECTORY + PluginSettings.FEATURE_SCENARIOS_PAGE_FRAGMENT +
feature.getIndex() + PluginSettings.HTML_FILE_EXTENSION);
}

// Tree view page
fileIO.writeContentToFile(
treeViewPageRenderer.getRenderedContent(
allFeaturesPageCollection,
allScenariosPageCollection,
templateEngine.getTemplate(TREE_VIEW)),
propertyManager.getGeneratedHtmlReportDirectory() + "/" + PluginSettings.PAGES_DIRECTORY + "/" +
PluginSettings.TREE_VIEW_PAGE_PATH + PluginSettings.HTML_FILE_EXTENSION);
}
}
Loading

0 comments on commit fa54afe

Please sign in to comment.