From 216f2aaa49788169a95b332ca6cbab21d6f2ffd6 Mon Sep 17 00:00:00 2001 From: Ian Moore Date: Sat, 14 Jan 2017 22:34:13 +0000 Subject: [PATCH] updated step decription at runtime with evaluated variables --- .../runner/node/StepImplementationNodeRunner.java | 10 ++++++++++ .../substeps/report/ExecutionResultsCollector.scala | 3 ++- .../substeps/runner/ExpressionEvaluationTest.scala | 12 ++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/technophobia/substeps/runner/node/StepImplementationNodeRunner.java b/core/src/main/java/com/technophobia/substeps/runner/node/StepImplementationNodeRunner.java index 9bea9d2f..9511170d 100644 --- a/core/src/main/java/com/technophobia/substeps/runner/node/StepImplementationNodeRunner.java +++ b/core/src/main/java/com/technophobia/substeps/runner/node/StepImplementationNodeRunner.java @@ -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); } diff --git a/core/src/main/scala/org/substeps/report/ExecutionResultsCollector.scala b/core/src/main/scala/org/substeps/report/ExecutionResultsCollector.scala index 314e0233..670ed62a 100644 --- a/core/src/main/scala/org/substeps/report/ExecutionResultsCollector.scala +++ b/core/src/main/scala/org/substeps/report/ExecutionResultsCollector.scala @@ -32,7 +32,8 @@ object ExecutionResultsCollector{ } -class ExecutionResultsCollector extends IExecutionResultsCollector { +class +ExecutionResultsCollector extends IExecutionResultsCollector { @transient private lazy val log: Logger = LoggerFactory.getLogger(classOf[ExecutionResultsCollector]) diff --git a/core/src/test/scala/org/substeps/runner/ExpressionEvaluationTest.scala b/core/src/test/scala/org/substeps/runner/ExpressionEvaluationTest.scala index 519b9ad9..3fac44e8 100644 --- a/core/src/test/scala/org/substeps/runner/ExpressionEvaluationTest.scala +++ b/core/src/test/scala/org/substeps/runner/ExpressionEvaluationTest.scala @@ -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 @@ -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() = { @@ -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")