Skip to content

Commit

Permalink
updated step decription at runtime with evaluated variables
Browse files Browse the repository at this point in the history
  • Loading branch information
iantmoore committed Jan 14, 2017
1 parent 8da5d70 commit 216f2aa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ protected boolean execute(StepImplementationNode node, RootNodeExecutionContext
}
}
evaluatedArgs = evaluatedArgsList.toArray();
node.setMethodArgs(evaluatedArgs);


SubSteps.Step stepAnnotation = node.getTargetMethod().getAnnotation(SubSteps.Step.class);
String rawSourceLine = stepAnnotation.value();

for (Object o : evaluatedArgsList){
rawSourceLine = rawSourceLine.replaceFirst("\\([^\\)]*\\)", o.toString());
}
node.setLine(rawSourceLine);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ object ExecutionResultsCollector{
}


class ExecutionResultsCollector extends IExecutionResultsCollector {
class
ExecutionResultsCollector extends IExecutionResultsCollector {

@transient
private lazy val log: Logger = LoggerFactory.getLogger(classOf[ExecutionResultsCollector])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class ExpressionEvaluationTest extends FlatSpec with ShouldMatchers with Feature
"""
| Feature: a simple feature
| Scenario: config and runtime expression scenario
| A step with a value from config "${users.default.name}"
| A step with a value from config "${users.default.name}" and one "hardcoded"
| SetupContext
| A step with param from context "${key.other.name}"
| A step with a "hardcoded" param and another from context "${key.other.name}"
|
""".stripMargin

Expand All @@ -49,8 +49,8 @@ class ExpressionEvaluationTest extends FlatSpec with ShouldMatchers with Feature
@StepImplementations
class StepImpls (){

@SubSteps.Step("""A step with a value from config "([^"]*)"""")
def stepPassedFromConfig(arg : String) = log.debug("stepPassedFromConfig: " + arg)
@SubSteps.Step("""A step with a value from config "([^"]*)" and one "([^"]*)"""")
def stepPassedFromConfig(arg : String, arg2: String) = log.debug("stepPassedFromConfig: " + arg)

@SubSteps.Step("SetupContext")
def setupContext() = {
Expand All @@ -59,8 +59,8 @@ class ExpressionEvaluationTest extends FlatSpec with ShouldMatchers with Feature
log.debug("SetupContext")
}

@SubSteps.Step("""A step with param from context "([^"]*)"""")
def stepPassedFromContext(arg: String) = log.debug("stepPassedFromContext: " + arg)
@SubSteps.Step("""A step with a "([^"]*)" param and another from context "([^"]*)"""")
def stepPassedFromContext(arg : String, arg2: String) = log.debug("stepPassedFromContext: " + arg2)
}

val featureFile = createFeatureFile(simpleFeature, "expression-evaluation.feature")
Expand Down

0 comments on commit 216f2aa

Please sign in to comment.