Skip to content

Commit

Permalink
more updates to the usage tree and reporting in general, WIP - non cr…
Browse files Browse the repository at this point in the history
…itical failures not clear
  • Loading branch information
iantmoore committed Oct 12, 2016
1 parent 59bc51b commit 8647f2b
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package com.technophobia.substeps.runner;

import java.io.File;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -59,6 +60,11 @@ public class SubstepsExecutionConfig implements Serializable {

private String[] executionListeners;

private File dataOutputDirectory;

private boolean checkForUncalledAndUnused = false;


public String getDescription() {
return description;
}
Expand Down Expand Up @@ -180,6 +186,24 @@ public void setScenarioName(String scenarioName) {
}


public File getDataOutputDirectory() {
return dataOutputDirectory;
}

public void setDataOutputDirectory(File dataOutputDirectory) {
this.dataOutputDirectory = dataOutputDirectory;
}

public boolean isCheckForUncalledAndUnused() {
return checkForUncalledAndUnused;
}

public void setCheckForUncalledAndUnused(boolean checkForUncalledAndUnused) {
this.checkForUncalledAndUnused = checkForUncalledAndUnused;
}



public String printParameters() {
return "SubstepExecutionConfig [description=" + getDescription() + ", tags=" + getTags() + ", nonFatalTags="
+ getNonFatalTags() + ", featureFile=" + getFeatureFile() + ", subStepsFileName="
Expand All @@ -189,6 +213,6 @@ public String printParameters() {
+ ", initialisationClass=" + Arrays.toString(getInitialisationClass()) + ", stepImplementationClasses="
+ getStepImplementationClasses() + ", initialisationClasses="
+ Arrays.toString(getInitialisationClasses()) + ", executionListeners="
+ Arrays.toString(getExecutionListeners()) + "]";
+ Arrays.toString(getExecutionListeners()) + "], dataOutputDirectory=" + getDataOutputDirectory();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class ExecutionNodeRunner implements SubstepsRunner {

private List<SubstepExecutionFailure> failures;

private final ReportingUtil reportingUtil = new ReportingUtil(new File("target"));
private final ReportingUtil reportingUtil = new ReportingUtil();

// map of nodes to each of the parents, where this node is used
private final Map<ExecutionNodeUsage, List<ExecutionNodeUsage>> callerHierarchy = new HashMap<ExecutionNodeUsage, List<ExecutionNodeUsage>>();
Expand All @@ -92,9 +92,11 @@ public RootNode prepareExecutionConfig(final ExecutionConfigWrapper configWrappe

setupExecutionListeners(configWrapper);

processUncalledAndUnused(syntax);
if (configWrapper.getExecutionConfig().isCheckForUncalledAndUnused()) {
processUncalledAndUnused(syntax, configWrapper.getExecutionConfig().getDataOutputDirectory());
}

UsageTreeBuilder.buildUsageTree(this.rootNode);
// UsageTreeBuilder.buildUsageTree(this.rootNode);

ExecutionContext.put(Scope.SUITE, INotificationDistributor.NOTIFIER_DISTRIBUTOR_KEY,
this.notificationDistributor);
Expand Down Expand Up @@ -200,21 +202,25 @@ private void setupExecutionListeners(ExecutionConfigWrapper configWrapper) {
/**
* @param syntax
*/
private void processUncalledAndUnused(final Syntax syntax) {
private void processUncalledAndUnused(final Syntax syntax, final File dataOutputDir) {
final List<StepImplementation> uncalledStepImplementations = syntax.getUncalledStepImplementations();

reportingUtil.writeUncalledStepImpls(uncalledStepImplementations);
if (!dataOutputDir.exists()){
dataOutputDir.mkdir();
}

reportingUtil.writeUncalledStepImpls(uncalledStepImplementations, dataOutputDir);

buildCallHierarchy();

checkForUncalledParentSteps(syntax);
checkForUncalledParentSteps(syntax, dataOutputDir);

}

/**
* @param syntax
*/
private void checkForUncalledParentSteps(final Syntax syntax) {
private void checkForUncalledParentSteps(final Syntax syntax, File outputDir) {

final Set<ExecutionNodeUsage> calledExecutionNodes = callerHierarchy.keySet();

Expand All @@ -230,7 +236,7 @@ private void checkForUncalledParentSteps(final Syntax syntax) {
uncalledSubstepDefs.add(parent);
}
}
reportingUtil.writeUncalledStepDefs(uncalledSubstepDefs);
reportingUtil.writeUncalledStepDefs(uncalledSubstepDefs, outputDir);
}

private boolean thereIsNotAStepThatMatchesThisPattern(final String stepPattern, final Set<ExecutionNodeUsage> calledExecutionNodes) {
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/org/substeps/report/ReportingUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
*/
public class ReportingUtil {

private final File outputDir;
// private final File outputDir;

public ReportingUtil(final File outputDir){
this.outputDir = outputDir;
}
// public ReportingUtil(final File outputDir){
// this.outputDir = outputDir;
// }

private static Logger log = LoggerFactory.getLogger(ReportingUtil.class);

Expand Down Expand Up @@ -77,7 +77,7 @@ public static Gson gson() {
return gson.create();
}

public void writeUncalledStepDefs(List<Step> uncalledSubstepDefs) {
public void writeUncalledStepDefs(List<Step> uncalledSubstepDefs, File outputDir) {

final StringBuilder buf = new StringBuilder();

Expand Down Expand Up @@ -114,7 +114,7 @@ public void writeUncalledStepDefs(List<Step> uncalledSubstepDefs) {
}


public void writeUncalledStepImpls(List<StepImplementation> uncalledStepImplementations){
public void writeUncalledStepImpls(List<StepImplementation> uncalledStepImplementations, File outputDir){


if (!uncalledStepImplementations.isEmpty()) {
Expand Down
Loading

0 comments on commit 8647f2b

Please sign in to comment.