Skip to content

Commit

Permalink
Merge pull request #25 from iantmoore/usage-report
Browse files Browse the repository at this point in the history
Usage report
  • Loading branch information
iantmoore committed Oct 26, 2016
2 parents c76a7c0 + d457973 commit 0e1776d
Show file tree
Hide file tree
Showing 80 changed files with 15,808 additions and 8,506 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ Requirements
-----
* Added a checkbox to the report to optionally hide skipped steps
* Substeps Mojos - Failures should prevent the Maven install phase from running; The runner mojo will throw a MojoFailureException only if the verify phase is not planned. The Report Builder will throw any such exception if one is encountered in the maven session.

* Report enhancements
* Upgraded Bootstrap to 3.3.7
* 3 progress bars rather than one, toggle to show data in original tabular form
* Step implementation method usage report (Beta)
* Replaced hand rolled recursive File listing with commons.io implementation
* Fixed Issue #24 - ExecutionResultsCollector didn't work with forked mode
* Added 3rd colour to usage report pie charts to show not run state
* Corrected the path to the screenshots in the report data and the final report

1.0.3
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,14 @@ public void setFailure(SubstepExecutionFailure substepExecutionFailure) {
EnumSet<ExecutionResult> excluded = EnumSet.of(ExecutionResult.PARSE_FAILURE, ExecutionResult.SETUP_TEARDOWN_FAILURE);

if (!excluded.contains(this.result)) {
this.result = ExecutionResult.FAILED;

if(substepExecutionFailure.isNonCritical()){
this.result = ExecutionResult.NON_CRITICAL_FAILURE;
}
else {
this.result = ExecutionResult.FAILED;
}

}

this.substepExecutionFailure = substepExecutionFailure;
Expand All @@ -144,4 +151,25 @@ public SubstepExecutionFailure getFailure() {
return substepExecutionFailure;
}

public Long getStartedAt() {
return startedAt;
}

public Long getCompletedAt() {
return completedAt;
}

public void setStartedAt(Long startedAt) {
this.startedAt = startedAt;
}

public void setCompletedAt(Long completedAt) {
this.completedAt = completedAt;
}

public void setSubstepExecutionFailure(SubstepExecutionFailure substepExecutionFailure) {
this.substepExecutionFailure = substepExecutionFailure;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public abstract class ExecutionNode implements Serializable, IExecutionNode {

private final ExecutionNodeResult result;

private List<String> parameterNames;
private String sourceLine;

public ExecutionNode() {
this.id = counter.getAndIncrement();
Expand Down Expand Up @@ -199,4 +201,20 @@ public String toDebugString() {
return debugString;
}

public String getSourceLine() {
return sourceLine;
}

public void setSourceLine(String sourceLine) {
this.sourceLine = sourceLine;
}

public void setParameterNames(List<String> parameterNames) {
this.parameterNames = parameterNames;
}

public List<String> getParameterNames() {
return parameterNames;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,37 @@ public Set<String> getTags() {
return tags;
}



public static boolean hasNonCriticalFailure(ExecutionNode node) {

// TODO
boolean rtn = false;

if (node.getResult().getResult() == ExecutionResult.CHILD_FAILED){
// there is a failure at a parent level, is the cause critical ?
// any child nodes with failures that are critical ?

if (node instanceof NodeWithChildren){
List<ExecutionNode> children = ((NodeWithChildren) node).getChildren();

for (ExecutionNode child : children){
rtn = hasNonCriticalFailure(child);
if (rtn){
break;
}
}
}

}
else if (node.getResult().getResult() == ExecutionResult.NON_CRITICAL_FAILURE) {
// real failure, is it critical ?
rtn = node.getResult().getFailure().isNonCritical();
}
return rtn;
}


public static boolean hasCriticalFailure(ExecutionNode node) {
boolean rtn = false;

Expand All @@ -98,4 +129,5 @@ else if (node.getResult().getResult() == ExecutionResult.FAILED) {
}
return rtn;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@ public interface IExecutionNode extends Serializable {
<RETURN_TYPE> RETURN_TYPE dispatch(ExecutionNodeVisitor<RETURN_TYPE> executionNodeVisitor);

<RETURN_TYPE> List<RETURN_TYPE> accept(ExecutionNodeVisitor<RETURN_TYPE> executionNodeVisitor);

String getSourceLine();
void setSourceLine(String sourceLine);

List<String> getParameterNames();
void setParameterNames(List<String> parameterNames);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.technophobia.substeps.execution.node;

import com.google.common.collect.Lists;
import com.technophobia.substeps.execution.ExecutionNodeResult;
import com.technophobia.substeps.execution.ExecutionNodeVisitor;

import java.util.List;
Expand All @@ -29,10 +30,25 @@ public class RootNode extends NodeWithChildren<FeatureNode> {

private final String featureSetDescription;

public RootNode(String featureSetDescription, List<FeatureNode> features) {
private final long timestamp;

private final String environment;
private final String tags;
private final String nonFatalTags;

public RootNode(String featureSetDescription, List<FeatureNode> features, String environment, String tags, String nonFatalTags) {
super(features);
this.featureSetDescription = featureSetDescription;
this.setDepth(0);
this.timestamp = System.currentTimeMillis();
this.environment = environment;
this.tags = tags;
this.nonFatalTags = nonFatalTags;
}

@Override
public ExecutionNodeResult getResult() {
return super.getResult();
}

@Override
Expand Down Expand Up @@ -62,4 +78,21 @@ public String getDescription() {
return featureSetDescription;
}

public long getTimestamp() {
return timestamp;
}

public String getEnvironment() {
return environment;
}

public String getTags() {
return tags;
}

public String getNonFatalTags() {
return nonFatalTags;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,36 @@ public class StepImplementationNode extends ExecutionNode implements StepNode {
private final transient Class<?> targetClass;
private final transient Method targetMethod;

private final String targetClassName;
private final String methodName;

private final Set<String> tags;

// FIXME: RB I'd prefer this to be final, it's like this because of the builder.
private transient Object[] methodArgs;




public StepImplementationNode(final Class<?> targetClass, final Method targetMethod, final Set<String> tags,
final int depth) {
this.targetClass = targetClass;
this.targetMethod = targetMethod;
this.setDepth(depth);
this.tags = tags;

if (targetClass.getDeclaringClass() != null) {
this.targetClassName = targetClass.getDeclaringClass().getName();
}
else {
this.targetClassName = targetClass.getName();
}
if (targetMethod != null){
this.methodName = targetMethod.getName();
}
else {
this.methodName = null;
}
}


Expand Down Expand Up @@ -136,7 +154,8 @@ public Set<String> getTags() {

@Override
public String toDebugString() {
return super.toDebugString() + " impl: "
+ this.targetMethod.getDeclaringClass().getSimpleName() + "." + this.targetMethod.getName();
return super.toDebugString() + " impl: " + targetClassName + "." + methodName;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.technophobia.substeps.execution.AbstractExecutionNodeVisitor;
import com.technophobia.substeps.execution.ExecutionResult;
import com.technophobia.substeps.execution.node.IExecutionNode;
import com.technophobia.substeps.execution.node.NodeWithChildren;
import com.technophobia.substeps.execution.node.RootNode;
Expand Down Expand Up @@ -106,7 +107,7 @@ private void addFailuresToLists(IExecutionNode node, List<IExecutionNode> parent
List<IExecutionNode> path = Lists.newArrayList(parents);
path.add(node);

if (node.getResult().getResult().isFailure()) { // nodes in a state of child_failed won't have the actual failure : node.getResult().getFailure()
if (node.getResult().getResult().isFailure() || node.getResult().getResult() == ExecutionResult.NON_CRITICAL_FAILURE) { // nodes in a state of child_failed won't have the actual failure : node.getResult().getFailure()

// child first
if (node instanceof NodeWithChildren<?>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.base.Function;
import com.technophobia.substeps.execution.ExecutionResult;
import com.technophobia.substeps.execution.node.IExecutionNode;
import com.technophobia.substeps.execution.node.StepImplementationNode;

import java.io.Serializable;

Expand Down Expand Up @@ -52,6 +53,47 @@ public Long apply(final SubstepExecutionFailure failure) {

private final ThrowableInfo throwableInfo;

private SubstepExecutionFailure(Throwable cause, IExecutionNode executionNode, boolean setupOrTearDown, boolean nonCritical, byte[] screenshot) {
this.cause = cause;
this.executionNode = executionNode;
this.setupOrTearDown = setupOrTearDown;
this.nonCritical = nonCritical;
this.screenshot = screenshot;
this.throwableInfo = new ThrowableInfo(cause);
}




public static SubstepExecutionFailure criticalFailure(Throwable cause, IExecutionNode node, byte[] screenshotBytes) {
SubstepExecutionFailure sef = new SubstepExecutionFailure(cause, node, false, false, screenshotBytes);

node.getResult().setFailure(sef);

return sef;

}


public static SubstepExecutionFailure nonCriticalFailure(final Throwable cause, final IExecutionNode node, byte[] screenshotBytes) {

SubstepExecutionFailure sef = new SubstepExecutionFailure(cause, node, false, true, screenshotBytes);

node.getResult().setFailure(sef);

return sef;
}

/*
* @param cause the cause of the failure
* @param node the node that failed execution
* @param screenshot the bytes representing the screenshot taken when the node execution failed
*/
// public SubstepExecutionFailure(final Throwable cause, final IExecutionNode node, final byte[] screenshot) {
// this(cause, node);
// this.setScreenshot(screenshot);
// }


public SubstepExecutionFailure(final Throwable cause) {

Expand All @@ -74,16 +116,6 @@ public SubstepExecutionFailure(final Throwable cause, final IExecutionNode node)
}


/**
* @param cause the cause of the failure
* @param node the node that failed execution
* @param screenshot the bytes representing the screenshot taken when the node execution failed
*/
public SubstepExecutionFailure(final Throwable cause, final IExecutionNode node, final byte[] screenshot) {
this(cause, node);
this.setScreenshot(screenshot);
}


/**
* @param cause the cause of the failure
Expand All @@ -106,10 +138,16 @@ public SubstepExecutionFailure(final Throwable cause, final IExecutionNode node,
node.getResult().setResult(result);
}



public static void setResult(final Throwable cause, final IExecutionNode node, final ExecutionResult result) {
final SubstepExecutionFailure sef = new SubstepExecutionFailure(cause);
sef.executionNode = node;
sef.executionNode.getResult().setFailure(sef);


final SubstepExecutionFailure sef = SubstepExecutionFailure.criticalFailure(cause, node, null);


// sef.executionNode = node;
// sef.executionNode.getResult().setFailure(sef);
node.getResult().setResult(result);
}

Expand Down Expand Up @@ -184,4 +222,5 @@ public byte[] getScreenshot() {
public void setScreenshot(final byte[] screenshot) {
this.screenshot = screenshot;
}

}
Loading

0 comments on commit 0e1776d

Please sign in to comment.