Skip to content

Commit

Permalink
Karate support (#330)
Browse files Browse the repository at this point in the history
* nested elements in steps, toggling of docstrings

* docstring specific toggles

* section margins work

* collapse

* updates, step hook buttons

* scenario sub section button

* rename

* shadows

* rerun

* updates

* individual step hook expansion

* moved cards

* layout cleanup

* fixed background step behavior

* changelog
  • Loading branch information
bischoffdev authored Mar 14, 2024
1 parent f6f7974 commit ba71e13
Show file tree
Hide file tree
Showing 34 changed files with 1,034 additions and 240 deletions.
183 changes: 165 additions & 18 deletions CHANGELOG.md

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ new CluecumberCore.Builder()

## Auto-expand Certain Report Sections

The `expandBeforeAfterHooks`, `expandStepHooks` and `expandDocStrings` options can be set to `true` to expand or
collapse before/after hooks, step hooks or docstrings respectively on scenario detail pages.
The `expandBeforeAfterHooks`, `expandStepHooks`, `expandDocStrings`, `expandOutputs` and `expandSubSections` options can be set to `true` to expand or
collapse before/after hooks, step hooks, docstrings, step outputs and sub sections respectively on scenario detail pages.

If they are not set, they default to false. This means that the report user has to use the buttons on a scenario detail
page to expand those sections on demand.
Expand All @@ -240,6 +240,8 @@ new CluecumberCore.Builder()
.setExpandBeforeAfterHooks(true)
.setExpandStepHooks(true)
.setExpandDocStrings(true)
.setExpandOutputs(true)
.expandSubSections(true)
.build().generateReports(jsonDirectory, reportDirectory);
```

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.5.1</version>
<version>3.6.0</version>
<packaging>jar</packaging>

<parent>
<artifactId>cluecumber-parent</artifactId>
<groupId>com.trivago.rta</groupId>
<version>3.5.1</version>
<version>3.6.0</version>
</parent>

<name>Cluecumber Core</name>
Expand Down
26 changes: 26 additions & 0 deletions core/src/main/java/com/trivago/cluecumber/core/CluecumberCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ private CluecumberCore(Builder builder) throws CluecumberException {
cluecumberEngine.setCustomStatusColorFailed(builder.customStatusColorFailed);
cluecumberEngine.setCustomStatusColorPassed(builder.customStatusColorPassed);
cluecumberEngine.setCustomStatusColorSkipped(builder.customStatusColorSkipped);
cluecumberEngine.setExpandSubSections(builder.expandSubSections);
cluecumberEngine.setExpandAttachments(builder.expandAttachments);
cluecumberEngine.setExpandBeforeAfterHooks(builder.expandBeforeAfterHooks);
cluecumberEngine.setExpandDocStrings(builder.expandDocStrings);
cluecumberEngine.setExpandOutputs(builder.expandOutputs);
cluecumberEngine.setExpandStepHooks(builder.expandStepHooks);
cluecumberEngine.setGroupPreviousScenarioRuns(builder.groupPreviousScenarioRuns);
cluecumberEngine.setExpandPreviousScenarioRuns(builder.expandPreviousScenarioRuns);
Expand Down Expand Up @@ -76,6 +78,7 @@ public static class Builder {
private String customStatusColorFailed;
private String customStatusColorPassed;
private String customStatusColorSkipped;
private boolean expandSubSections;
private boolean expandAttachments;
private boolean expandBeforeAfterHooks;
private boolean expandDocStrings;
Expand All @@ -85,6 +88,7 @@ public static class Builder {
private String logLevel;
private String startPage;
private boolean failScenariosOnPendingOrUndefinedSteps;
private boolean expandOutputs;

/**
* Finalize the {@link CluecumberCore} builder.
Expand Down Expand Up @@ -186,6 +190,17 @@ public Builder setCustomStatusColorSkipped(final String customStatusColorSkipped
return this;
}

/**
* Whether to expand sub sections or not.
*
* @param expandSubSections If true, sub sections will be expanded.
* @return The {@link Builder}.
*/
public Builder setExpandSubSections(final boolean expandSubSections) {
this.expandSubSections = expandSubSections;
return this;
}

/**
* Whether to expand attachments or not.
*
Expand All @@ -197,6 +212,17 @@ public Builder setExpandAttachments(final boolean expandAttachments) {
return this;
}

/**
* Whether to expand stepoutputs or not.
*
* @param expandOutputs If true, outputs will be expanded.
* @return The {@link Builder}.
*/
public Builder setExpandOutputs(final boolean expandOutputs) {
this.expandOutputs = expandOutputs;
return this;
}

/**
* Whether to expand before and after hooks or not.
*
Expand Down
12 changes: 6 additions & 6 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.5.1</version>
<version>3.6.0</version>
</parent>

<artifactId>cluecumber-engine</artifactId>
<version>3.5.1</version>
<version>3.6.0</version>
<packaging>jar</packaging>

<name>Cluecumber Engine</name>
Expand All @@ -29,11 +29,11 @@
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<tinylog-impl.version>2.6.2</tinylog-impl.version>
<freemarker.version>2.3.31</freemarker.version>
<gson-fire.version>1.9.0-alpha2</gson-fire.version>
<tinylog-impl.version>2.7.0</tinylog-impl.version>
<freemarker.version>2.3.32</freemarker.version>
<gson-fire.version>1.9.0</gson-fire.version>
<gson.version>2.10.1</gson.version>
<dagger.version>2.45</dagger.version>
<dagger.version>2.51</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 @@ -63,14 +63,14 @@ public final class CluecumberEngine {
/**
* Constructor for dependency injection.
*
* @param elementIndexPreProcessor The {@link ElementIndexPreProcessor} instance.
* @param elementIndexPreProcessor The {@link ElementIndexPreProcessor} instance.
* @param elementMultipleRunsPreProcessor The {@link ElementMultipleRunsPreProcessor} instance.
* @param fileIO The {@link FileIO} instance.
* @param fileSystemManager The {@link FileSystemManager} instance.
* @param jsonPojoConverter The {@link JsonPojoConverter} instance.
* @param logger The {@link CluecumberLogger} instance.
* @param propertyManager The {@link PropertyManager} instance.
* @param reportGenerator The {@link ReportGenerator} instance.
* @param fileIO The {@link FileIO} instance.
* @param fileSystemManager The {@link FileSystemManager} instance.
* @param jsonPojoConverter The {@link JsonPojoConverter} instance.
* @param logger The {@link CluecumberLogger} instance.
* @param propertyManager The {@link PropertyManager} instance.
* @param reportGenerator The {@link ReportGenerator} instance.
*/
@Inject
public CluecumberEngine(
Expand Down Expand Up @@ -133,14 +133,14 @@ public void build(
logger.warn("Could not parse JSON in file '" + jsonFilePath + "': " + e.getMessage());
}
}
elementIndexPreProcessor.addScenarioIndices(allScenariosPageCollection.getReports());
elementIndexPreProcessor.process(allScenariosPageCollection.getReports());
if (propertyManager.isGroupPreviousScenarioRuns()) {
elementMultipleRunsPreProcessor.addMultipleRunsInformationToScenarios(allScenariosPageCollection.getReports());
}
reportGenerator.generateReport(allScenariosPageCollection);
logger.info(
"=> Cluecumber Report: " + propertyManager.getGeneratedHtmlReportDirectory() + "/" +
Settings.START_PAGE + Settings.HTML_FILE_EXTENSION,
Settings.START_PAGE + Settings.HTML_FILE_EXTENSION,
DEFAULT,
COMPACT,
MINIMAL
Expand Down Expand Up @@ -199,6 +199,15 @@ public void setFailScenariosOnPendingOrUndefinedSteps(final boolean failScenario
propertyManager.setFailScenariosOnPendingOrUndefinedSteps(failScenariosOnPendingOrUndefinedSteps);
}

/**
* Set if sub sections should be expanded by default.
*
* @param expandSubSections If true, sub sections will be expanded by default.
*/
public void setExpandSubSections(final boolean expandSubSections) {
propertyManager.setExpandSubSections(expandSubSections);
}

/**
* Whether to expand before and after hooks or not.
*
Expand Down Expand Up @@ -235,6 +244,15 @@ public void setExpandAttachments(final boolean expandAttachments) {
propertyManager.setExpandAttachments(expandAttachments);
}

/**
* Whether to expand step outputs or not.
*
* @param expandOutputs If true, outputs will be expanded.
*/
public void setExpandOutputs(final boolean expandOutputs) {
propertyManager.setExpandOutputs(expandOutputs);
}

/**
* Whether to show the scenarios run multiple times should be grouped and the show not last run toggle should be shown.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.trivago.cluecumber.engine.json.pojo;

class Argument {
public class Argument {
private String val;
private int offset;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class Element {
private List<Tag> tags = new ArrayList<>();
@SerializedName("start_timestamp")
private String startTimestamp = "";
private List<Element> childrenElements = new ArrayList<>();;
private List<Element> childrenElements = new ArrayList<>();
;

private transient int featureIndex = 0;
private transient int scenarioIndex = 0;
Expand Down Expand Up @@ -374,7 +375,7 @@ public Status getStatus() {
return Status.SKIPPED;
}
if (failOnPendingOrUndefined && allStates.size() == 1
&& allStates.iterator().next().basicStatus() == Status.SKIPPED) {
&& allStates.iterator().next().basicStatus() == Status.SKIPPED) {
return Status.FAILED;
}

Expand Down Expand Up @@ -587,6 +588,54 @@ public boolean hasDocStrings() {
return false;
}

/**
* Check if this scenario contains outputs.
*
* @return true if there are outputs.
*/
public boolean hasOutputs() {
for (Step step : backgroundSteps) {
if (step.hasOutputs()) {
return true;
}
}
for (Step step : steps) {
if (step.hasOutputs()) {
return true;
}
}
return false;
}

/**
* Check if this scenario contains attachments.
*
* @return true if there are attachments.
*/
public boolean hasAttachments() {
for (ResultMatch resultMatch : before) {
if (!resultMatch.getEmbeddings().isEmpty()) {
return true;
}
}
for (Step step : backgroundSteps) {
if (step.hasEmbeddings()) {
return true;
}
}
for (Step step : steps) {
if (step.hasEmbeddings()) {
return true;
}
}
for (ResultMatch resultMatch : after) {
if (!resultMatch.getEmbeddings().isEmpty()) {
return true;
}
}
return false;
}

/**
* Check if this scenario contains hooks.
*
Expand All @@ -612,6 +661,25 @@ public boolean hasStepHooks() {
return false;
}

/**
* Check if this scenario contains sub-sections.
*
* @return true if there are sub-sections.
*/
public boolean hasSubSections() {
for (Step step : backgroundSteps) {
if (step.hasSubSections()) {
return true;
}
}
for (Step step : steps) {
if (step.hasSubSections()) {
return true;
}
}
return false;
}

/**
* Check if any step hooks have content.
*
Expand Down Expand Up @@ -727,6 +795,7 @@ public boolean getIsLastOfMultipleScenarioRuns() {

/**
* Set to true if this scenario is the last of multiple runs.
*
* @param isLastOfMultipleScenarioRuns true if this scenario is the last of multiple runs.
*/
public void setIsLastOfMultipleScenarioRuns(final boolean isLastOfMultipleScenarioRuns) {
Expand All @@ -744,6 +813,7 @@ public boolean getIsNotLastOfMultipleScenarioRuns() {

/**
* Set to true if this scenario was run multiple times and it's not the last run.
*
* @param isNotLastOfMultipleScenarioRuns true if this scenario was run multiple times and it's not the last run.
*/
public void setIsNotLastOfMultipleScenarioRuns(final boolean isNotLastOfMultipleScenarioRuns) {
Expand All @@ -752,6 +822,7 @@ public void setIsNotLastOfMultipleScenarioRuns(final boolean isNotLastOfMultiple

/**
* Get the children elements of this scenario.
*
* @return The children elements.
*/
public List<Element> getChildrenElements() {
Expand All @@ -760,6 +831,7 @@ public List<Element> getChildrenElements() {

/**
* Set the children elements of this scenario.
*
* @param childrenElements The children elements.
*/
public void setChildrenElements(final List<Element> childrenElements) {
Expand All @@ -777,6 +849,7 @@ public void setFeatureUri(String featureUri) {

/**
* Get all steps including background steps.
*
* @return The list of steps.
*/
public List<Step> getAllStepsIncludingBackgroundSteps() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void setEmbeddings(final List<Embedding> embeddings) {
* @return true if attachments exist.
*/
public boolean hasEmbeddings() {
return embeddings.size() > 0;
return !embeddings.isEmpty();
}

/**
Expand All @@ -119,7 +119,7 @@ public void setOutput(final List<String> output) {
* @return true if outputs exist.
*/
public boolean hasOutputs() {
return output.size() > 0;
return !output.isEmpty();
}

/**
Expand Down
Loading

0 comments on commit ba71e13

Please sign in to comment.