Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Apr 26, 2024
2 parents fb691b2 + a604a05 commit 3e06415
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@ public List<TestStep> getChildren() {
return new ArrayList(children);
}

public String getAllStepsText() {
StringBuilder allStepsText = new StringBuilder();
for (TestStep testStep : getFlattenedSteps()) {
allStepsText.append(testStep.getDescription() + "\n");
}
return allStepsText.toString();
}

public List<ScreenshotAndHtmlSource> getScreenshots() {
return new ArrayList(screenshots);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,16 @@ public long getScenarioCount() {
.count();
}

public String getAllStepsText() {
StringBuilder allStepsText = new StringBuilder();
for (TestOutcome outcome : outcomes) {
for (TestStep testStep : outcome.getFlattenedTestSteps()) {
allStepsText.append(testStep.getDescription() + "\n");
}
}
return allStepsText.toString();
}

private int totalImplementedTests() {
return outcomes.stream()
.mapToInt(TestOutcome::getImplementedTestCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ public class ExampleOutcome {
private ZonedDateTime startTime;
private final long duration;
private final long stepCount;
private final String allStepsText;

public ExampleOutcome(String title, String subtitle, TestResult result, ZonedDateTime startTime, long duration, long stepCount) {
public ExampleOutcome(String title, String subtitle, TestResult result, ZonedDateTime startTime, long duration, long stepCount, String allStepsText) {
this.title = title;
this.subtitle = subtitle;
this.result = result;
this.startTime = startTime;
this.duration = duration;
this.stepCount = stepCount;
this.allStepsText = allStepsText;
}

public String getTitle() {
Expand Down Expand Up @@ -50,6 +52,10 @@ public long getStepCount() {
return stepCount;
}

public String getAllStepsText() {
return allStepsText;
}

public String getFormattedStartTime() {
return (startTime != null) ? "" + startTime.format(DateTimeFormatter.ofPattern("HH:mm:ss")) : "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public static List<ExampleOutcome> from(TestOutcome outcome) {
testStep.getResult(),
testStep.getStartTime(),
testStep.getDuration(),
testStep.getChildren().size()
testStep.getChildren().size(),
testStep.getAllStepsText()
)).collect(Collectors.toList());
} else {
return new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ public long getScenarioCount() {
return testOutcomes.getScenarioCount();
}

public String getAllStepsText() {
return testOutcomes.getAllStepsText();
}

public long getTestCount() {
return testOutcomes.getTotal();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ public long getScenarioCount() {
return this.testOutcomes.getScenarioCount();
}

public String getAllStepsText() {
return this.testOutcomes.getAllStepsText();
}

public List<Requirement> getRequirements() {
return requirementOutcomes.stream().map(RequirementOutcome::getRequirement).collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public interface ScenarioOutcome {

Integer getStepCount();

String getAllStepsText();

ZonedDateTime getStartTime();

Long getTimestamp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ public Integer getStepCount() {
return steps.size();
}

public String getAllStepsText() {
StringBuilder allStepsText = new StringBuilder();
for (String step : steps) {
allStepsText.append(step + "\n");
}
return allStepsText.toString();
}

public List<TestCaseResultCount> getResultCounts() {
List<TestCaseResultCount> resultCounts = new ArrayList<>();
// Create an initial list of results in a logical order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class SingleScenarioOutcome implements ScenarioOutcome {
private Rule rule;
private ExternalLink externalLink;
private final Collection<TestTag> scenarioTags;

private final String context;

public SingleScenarioOutcome(String name,
Expand Down Expand Up @@ -157,6 +156,13 @@ public Integer getStepCount() {
return steps.size();
}

public String getAllStepsText() {
StringBuilder allStepsText = new StringBuilder();
for (String step : steps) {
allStepsText.append(step + "\n");
}
return allStepsText.toString();
}

public ZonedDateTime getStartTime() {
return startTime;
Expand Down
48 changes: 39 additions & 9 deletions serenity-report-resources/src/main/resources/freemarker/home.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
search: ""
},
columnDefs: [
{type: 'time-elapsed-dhms', targets: 5}
{
targets: 4,
visible: false
},
{type: 'time-elapsed-dhms', targets: 6}
]
})
$("#manual-scenario-results").DataTable({
Expand All @@ -60,6 +64,12 @@
searchPlaceholder: "Filter",
search: ""
},
columnDefs: [
{
targets: 4,
visible: false
},
]
})
// Results table
Expand All @@ -80,7 +90,17 @@
$(".feature-coverage-table").DataTable({
searching: true,
paging: false,
info: false
info: false,
language: {
searchPlaceholder: "Filter",
search: ""
},
columnDefs: [
{
targets: 2,
visible: false
},
]
});
$(".feature-coverage-table-with-pagination").DataTable({
Expand All @@ -90,7 +110,13 @@
language: {
searchPlaceholder: "Filter",
search: ""
}
},
columnDefs: [
{
targets: 2,
visible: false
},
]
});
});
</script>
Expand Down Expand Up @@ -331,12 +357,12 @@
<#assign sectionTitle = inflection.of(tagCoverageByType.tagType).inPluralForm().asATitle() >
<h4>${inflection.of(tagCoverageByType.tagType).inPluralForm().asATitle()}</h4>

<table class="table ${coverageTableClass}"
id="${tagCoverageByType.tagType}">
<table class="table ${coverageTableClass}" id="${tagCoverageByType.tagType}" style="width:100%">
<thead>
<tr>
<th>${formatter.humanReadableFormOf(tagCoverageByType.tagType)}</th>
<th style="width:1em;">Scenarios</th>
<th style="width:1em;">StepsText</th>
<th style="width:1em;">Test&nbsp;Cases</th>
<th style="width:1em;">%&nbsp;Pass</th>
<th style="width:1em;">Result</th>
Expand All @@ -361,6 +387,7 @@
</#if>
</td>
<td>${tagCoverage.scenarioCount}</td>
<td>${tagCoverage.allStepsText}</td>
<td>${tagCoverage.testCount}</td>
<td>${tagCoverage.successRate}</td>
<td>
Expand Down Expand Up @@ -452,14 +479,14 @@
<h3><i class="bi bi-gear"></i> Automated Scenarios</h3>

<#if (automatedTestCases?has_content)>
<table class="scenario-result-table table"
id="scenario-results">
<table class="scenario-result-table table" id="scenario-results" style="width:100%">
<thead>
<tr>
<th>${leafRequirementType}</th>
<th class="test-name-column">Scenario</th>
<th>Context</th>
<th>Steps</th>
<th>StepsText</th>
<th>Started</th>
<th>Total Duration</th>
<th>Result</th>
Expand Down Expand Up @@ -501,6 +528,7 @@
<td>${context_icon}<span style="display:none">${context_label}</span>
</td>
<td>${scenario.stepCount}</td>
<td>${scenario.allStepsText}</td>
<td data-order="${scenario.timestamp}">${scenario.formattedStartTime}</td>
<td>${scenario.formattedDuration}</td>
<td>${outcome_icon} <span
Expand All @@ -522,14 +550,14 @@
<h3><i class="bi bi-hand-index-thumb"></i> Manual Tests</h3>

<#if (manualTestCases?has_content)>
<table class="scenario-result-table table"
id="manual-scenario-results">
<table class="scenario-result-table table" id="manual-scenario-results" style="width:100%">
<thead>
<tr>
<th>${leafRequirementType}</th>
<th class="test-name-column">Scenario</th>
<th>Context</th>
<th>Steps</th>
<th>StepsText</th>
<th>Result</th>
</tr>
</thead>
Expand Down Expand Up @@ -557,6 +585,7 @@
</td>
<td><i class="bi bi-person"></i></td>
<td>${exampleOutcome.stepCount}</td>
<td>${exampleOutcome.allStepsText}</td>
<td>${example_outcome_icon} <span
style="display:none">${exampleOutcome.result}</span>
<#if (scenario.externalLink)?? && (scenario.externalLink.url)??>
Expand All @@ -582,6 +611,7 @@
</td>
<td><i class="bi bi-person"></i></td>
<td>${scenario.stepCount}</td>
<td>${scenario.allStepsText}</td>
<td>${outcome_icon} <span
style="display:none">${scenario.result}</span>
<#if (scenario.externalLink)?? && (scenario.externalLink.url)??>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class CoverageByTagType(
testOutcomesForTag.testCaseCount,
successRate,
testOutcomesForTag.result,
testOutcomesForTag.allStepsText,
reportNameProvider.forRequirementOrTag(testTag), // ReportNameProvider().forRequirementOrTag(testTag),
countByResultLabelFrom(testOutcomesForTag),
percentageByResultFrom(testOutcomesForTag)
Expand Down Expand Up @@ -191,6 +192,7 @@ class CoverageByTag(
val testCount: Long,
val successRate: String,
val result: TestResult,
var allStepsText: String,
val report: String,
val countByResult: Map<String, Long>,
val percentageByResult: Map<String, Double>
Expand Down

0 comments on commit 3e06415

Please sign in to comment.