Skip to content

Commit

Permalink
do not show excluded cucumber examples in report - bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
cliviu committed Oct 11, 2019
1 parent 72539fc commit 92c849f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
import net.thucydides.core.requirements.model.Requirement;
import net.thucydides.core.requirements.model.cucumber.AnnotatedFeature;
import net.thucydides.core.requirements.model.cucumber.CucumberParser;
import net.thucydides.core.requirements.reports.*;
import net.thucydides.core.requirements.reports.ReportBadges;
import net.thucydides.core.requirements.reports.RequirementsOutcomes;
import net.thucydides.core.requirements.reports.ScenarioOutcome;
import net.thucydides.core.requirements.reports.ScenarioSummaryOutcome;
import net.thucydides.core.tags.TagScanner;
import net.thucydides.core.util.EnvironmentVariables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.net.URL;
Expand All @@ -22,12 +28,17 @@

public class FeatureFileScenarioOutcomes {


private static final Logger LOGGER = LoggerFactory.getLogger(FeatureFileScenarioOutcomes.class);

private Requirement requirement;
private EnvironmentVariables environmentVariables;
private TagScanner tagScanner;

public FeatureFileScenarioOutcomes(Requirement requirement, EnvironmentVariables environmentVariables) {
this.requirement = requirement;
this.environmentVariables = environmentVariables;
this.tagScanner = new TagScanner(environmentVariables);
}

public FeatureFileScenarioOutcomes(Requirement requirement) {
Expand All @@ -48,9 +59,9 @@ public List<ScenarioOutcome> forOutcomesIn(RequirementsOutcomes requirementsOutc
List<ScenarioOutcome> scenarioOutcomes = new ArrayList<>();
feature.get().getFeature().getChildren().forEach(
scenarioDefinition -> scenarioOutcomes.add(
scenarioOutcomeFrom(feature.get().getFeature(),
scenarioDefinition,
requirementsOutcomes.getTestOutcomes()))
scenarioOutcomeFrom(feature.get().getFeature(),
scenarioDefinition,
requirementsOutcomes.getTestOutcomes()))
);
return scenarioOutcomes;
}
Expand All @@ -65,24 +76,41 @@ private ScenarioOutcome scenarioOutcomeFrom(Feature feature,
String scenarioTitle = scenarioDefinition.getName();

TestResult result = (outcomes.isEmpty()) ? TestResult.UNDEFINED :
TestResultList.overallResultFrom(outcomes.stream().map(TestOutcome::getResult).collect(Collectors.toList()));
TestResultList.overallResultFrom(outcomes.stream().map(TestOutcome::getResult).collect(Collectors.toList()));

List<String> reportBadges = ReportBadges.from(outcomes, scenarioDefinition.getName());

String featureReport = new ReportNameProvider().forRequirement(feature.getName(),"feature");
Optional<String> scenarioReport = (outcomes.isEmpty()) ? Optional.empty() : Optional.of(outcomes.get(0).getHtmlReport());

List<String> renderedSteps = scenarioDefinition.getSteps().stream()
.map(RenderCucumber::step)
.collect(Collectors.toList());
.map(RenderCucumber::step)
.collect(Collectors.toList());

List<Examples> filteredExamples = new ArrayList<Examples>();
if((scenarioDefinition instanceof ScenarioOutline)) {
List<Examples> examples = ((ScenarioOutline) scenarioDefinition).getExamples();
for(Examples ex : examples) {
if(ex.getTags().size() > 0) {
List<String> alltagNames = ex.getTags().stream().map(Tag::getName).collect(Collectors.toList());
if(tagScanner.shouldRunForTags(alltagNames)){
LOGGER.info("Added example " + ex.getName());
filteredExamples.add(ex);
}
} else {
filteredExamples.add(ex);
}
}
}

List<Examples> examplesList = filteredExamples;
List<String> renderedExamples = (scenarioDefinition instanceof ScenarioOutline) ?
RenderCucumber.examples(((ScenarioOutline) scenarioDefinition).getExamples(),
feature.getName(),
scenarioDefinition.getName()) : Collections.EMPTY_LIST;
RenderCucumber.examples(examplesList,
feature.getName(),
scenarioDefinition.getName()) : Collections.EMPTY_LIST;

int exampleCount = (scenarioDefinition instanceof ScenarioOutline) ?
((ScenarioOutline) scenarioDefinition).getExamples().stream().mapToInt(examples -> examples.getTableBody().size()).sum()
examplesList.stream().mapToInt(examples -> examples.getTableBody().size()).sum()
: 0;

Boolean isManual = (outcomes.size() == 1) ? outcomes.get(0).isManual() : hasManualTag(feature.getTags());
Expand Down

0 comments on commit 92c849f

Please sign in to comment.