Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique names for outline results #60

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Requirements
* Moved substeps config to a single org.substeps hierarchy, existing overrides will still be used, but config should be updated
* Moved maven pom configuration to config files (multiple). Maven plugin will print out the new config from existing pom settings, see [1.1.0 Upgrade notes](1.1.0 Upgrade.md) for further details
* Added an exclusion filter to the config for the glossary builder under `org.substeps.config.glossary.excludeStepImplementationClassNames`
* Scenario and Outline results files appended with their offset to enable outlines that don't include a dynamic name parameter or duplicate named scenarios. Issue #49 and #53
* Added an annotated config file for reference

1.0.6
-----
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/com/technophobia/substeps/model/Step.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ public Step(final String theLine, final boolean isSubstep, final File source, fi

// TODO no need to to do if no parameter to the annotation..?

log.debug("Step ctor() for line: " + this.line + " isSubstep: " + isSubstep);
log.trace("Step ctor() for line: " + this.line + " isSubstep: " + isSubstep);
if (this.isSubstep) {
log.debug("calling setParamAndParamNames");
log.trace("calling setParamAndParamNames");
setParamAndParamNames();
}

Expand Down Expand Up @@ -163,24 +163,24 @@ private void setParamAndParamNames() {
this.paramNames = new ArrayList<String>();
}
final String s = matcher.group(2);
log.debug("adding " + s + " as a paramname");
log.trace("adding " + s + " as a paramname");
this.paramNames.add(s);
findIdx = matcher.end(2);
}

// replace the params with a reg ex, a quoted and non quoted variant
log.debug("line pre replace: " + line + "\npattern: " + pattern);
log.trace("line pre replace:[" + line + "] pattern: " + pattern);

this.pattern = this.line.replaceAll("(<[^>]*>)", "\"?([^\"]*)\"?");

log.debug("line post replace: " + line + "\npattern: " + pattern);
log.trace("line post replace: [" + line + "] pattern: " + pattern);


}

public String toDebugString() {
if (this.keyword == null) {
this.log.debug("annot of step is null: " + this.getClass().getSimpleName());
this.log.trace("annot of step is null: " + this.getClass().getSimpleName());
}

return " [" + this.line + "]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ class ExecutionResultsCollector extends IExecutionResultsCollector {
}
case Some(dir) => {

val name: String = getScenarioName(node, scenarioNode)

// write out a results file for this scenario
val resultsFile = new File(dir, scenarioNode.getScenarioName.replaceAllLiterally(" ", "_") + "_results.json")
val screenshotsDir = new File(dir, scenarioNode.getScenarioName.replaceAllLiterally(" ", "_"))
val resultsFile = new File(dir, name + "_results.json")
val screenshotsDir = new File(dir, name)

scenarioSummaryMap += scenarioNode.getId -> (scenarioNode, resultsFile)

Expand Down Expand Up @@ -174,10 +176,12 @@ class ExecutionResultsCollector extends IExecutionResultsCollector {
}
case Some(dir) => {

val name: String = getScenarioName(node, scenarioNode)

// write out a results file for this scenario
val resultsFile = new File(dir, scenarioNode.getScenarioName.replaceAllLiterally(" ", "_") + "_results.json")
val resultsFile = new File(dir, name + "_results.json")

val screenshotsDir = new File(dir, scenarioNode.getScenarioName.replaceAllLiterally(" ", "_"))
val screenshotsDir = new File(dir, name)

scenarioSummaryMap += scenarioNode.getId -> (scenarioNode, resultsFile)

Expand Down Expand Up @@ -218,6 +222,17 @@ class ExecutionResultsCollector extends IExecutionResultsCollector {

}

private def getScenarioName(node: IExecutionNode, scenarioNode: BasicScenarioNode) = {
val idx =
node.getParent match {
case row: OutlineScenarioRowNode => row.getParent.asInstanceOf[OutlineScenarioNode].getChildren.indexOf(row)
case featureNode : FeatureNode => featureNode.getChildren.indexOf(node)
case _ => 0
}
val name = scenarioNode.getScenarioName.replaceAllLiterally(" ", "_") + "_" + idx
name
}

def onNodeIgnored(node: IExecutionNode): Unit = {

log.debug("ExecutionResultsCollector nodeIgnored: " + node.getId)
Expand Down
105 changes: 105 additions & 0 deletions core/src/test/resources/annotated.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@

org {
substeps {
config {
current {
branchname="" // automatically populated by JGit, if using git
projectversion="" // automatically populated via maven
}

description="Substeps test suite" // name of the whole test suite

executionResultsCollector="org.substeps.report.ExecutionResultsCollector"
// class responsible for collecting execution result data

jmxPort=9999 // JMX port used when Substeps run in forked mode

log {
unused {
uncalled=false // when set to true, uncalled and unsued steps and step impls are logged
// can lead to spurious results if running a set of tags or specific scenarios
}
}
parameter {
substitution {
enabled=true // allows ${} syntax in steps and scenarios
start="${" // token delimiters used for the expression
end="}"

normalizeValue=false // if true then values located will be converted from one charset to another
// useful when the config files contains accented characters pasted in

normalize {
from=ISO-8859-1 // the from charset
to=UTF-8 // converted to..
}
}
}

report {
data {
base {
dir=target // legacy value to specify root location of report
}
pretty {
print=false // pretty print report json
}
}
rootNodeDescriptionProvider="org.substeps.report.DefaultDescriptionProvider"
// class to describe the root level node in the report
}

reportBuilder="org.substeps.report.ReportBuilder"
// class that builds the report

reportDir="target/substeps_report"
// directory in which to build the report

rootDataDir="src/test/resources/sample-results-data"
// directory in which to write results into, and for the report builder to pick up from


runTestsInForkedVM=false // run the substeps in a forked VM ?

step {
depth {
description=6 // beyond 6 deep, the Junit runner won't render a description
}
}
}



baseExecutionConfig {
// all execution configs (below) inherit this config

executionListeners=[
// set of listeners that receive test started / passed / failed events
"com.technophobia.substeps.runner.logger.StepExecutionLogger"
]
fastFailParseErrors=true
// if true, parse failures of all scenarios and substeps result in immediate termination.
// During development it may be beneficial to relax this. Parse errors found during execution are
// still treated as an error
}




executionConfigs=[
// an array of execution configs, each one will be executed sequentially

{
dataOutputDir="1"
description="Substeps test execution description"
fastFailParseErrors=true
featureFile=null
stepImplementationClassNames=[
"org.substeps.runner.ParsingFromSourceTests$$anonfun$5$StepImpls$3"
]
substepsFile=null
tags=null
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"lineNumber":0,
"result":"PASSED",
"id":56,
"executionDurationMillis":0,
"executionDurationMillis":1,
"description":"a basic scenario outline one",
"children":[
{
Expand All @@ -15,7 +15,7 @@
"id":52,
"executionDurationMillis":0,
"description":"PassingStepImpl",
"method":"public void org.substeps.runner.ParsingFromSourceTests$$anonfun$5$StepImpls$3.passingStepImpl()",
"method":"public void org.substeps.runner.ParsingFromSourceTests$$anonfun$11$StepImpls$3.passingStepImpl()",
"children":[

],
Expand All @@ -38,7 +38,7 @@
"id":53,
"executionDurationMillis":0,
"description":"AnotherPassingStepImpl",
"method":"public void org.substeps.runner.ParsingFromSourceTests$$anonfun$5$StepImpls$3.anotherPassingStepImpl()",
"method":"public void org.substeps.runner.ParsingFromSourceTests$$anonfun$11$StepImpls$3.anotherPassingStepImpl()",
"children":[

],
Expand All @@ -55,7 +55,7 @@
"id":55,
"executionDurationMillis":0,
"description":"PassingStepImpl with param 1",
"method":"public void org.substeps.runner.ParsingFromSourceTests$$anonfun$5$StepImpls$3.passingStepImplWithParam(java.lang.String)",
"method":"public void org.substeps.runner.ParsingFromSourceTests$$anonfun$11$StepImpls$3.passingStepImplWithParam(java.lang.String)",
"children":[

],
Expand Down
Loading