@@ -5,6 +5,7 @@ import java.lang.reflect.{ParameterizedType, Type}
55import cucumber .api .Scenario
66import cucumber .runtime .{HookDefinition , StepDefinition }
77import cucumber .runtime .scala .{ScalaHookDefinition , ScalaStepDefinition }
8+ import io .cucumber .stepexpression .TypeRegistry
89
910import scala .collection .mutable .ArrayBuffer
1011
@@ -16,13 +17,21 @@ trait ScalaDsl {
1617 self =>
1718 import scala .language .implicitConversions
1819
19-
20- private [cucumber] val stepDefinitions = new ArrayBuffer [StepDefinition ]
20+ private val stepDefinitions = new ArrayBuffer [StepDefinition ]
2121
2222 private [cucumber] val beforeHooks = new ArrayBuffer [HookDefinition ]
2323
24+ private [cucumber] val beforeStepHooks = new ArrayBuffer [HookDefinition ]
25+
2426 private [cucumber] val afterHooks = new ArrayBuffer [HookDefinition ]
2527
28+ private [cucumber] val afterStepHooks = new ArrayBuffer [HookDefinition ]
29+
30+ private [cucumber] def getStepDefs (typeRegistry : TypeRegistry ): ArrayBuffer [StepDefinition ]= {
31+ stepDefinitions.foreach(d=> d.asInstanceOf [ScalaStepDefinition ].typeRegistry = typeRegistry)
32+ stepDefinitions
33+ }
34+
2635 def Before (f : Scenario => Unit ) {
2736 Before ()(f)
2837 }
@@ -35,6 +44,18 @@ trait ScalaDsl {
3544 beforeHooks += new ScalaHookDefinition (f, order, tags)
3645 }
3746
47+ def BeforeStep (f : Scenario => Unit ) {
48+ BeforeStep ()(f)
49+ }
50+
51+ def BeforeStep (tags : String * )(f : Scenario => Unit ) {
52+ BeforeStep (Int .MaxValue , tags : _* )(f)
53+ }
54+
55+ def BeforeStep (order : Int , tags : String * )(f : Scenario => Unit ) {
56+ beforeStepHooks += new ScalaHookDefinition (f, order, tags)
57+ }
58+
3859 def After (f : Scenario => Unit ) {
3960 After ()(f)
4061 }
@@ -47,6 +68,19 @@ trait ScalaDsl {
4768 afterHooks += new ScalaHookDefinition (f, order, tags)
4869 }
4970
71+ def AfterStep (f : Scenario => Unit ) {
72+ AfterStep ()(f)
73+ }
74+
75+ def AfterStep (tags : String * )(f : Scenario => Unit ) {
76+ AfterStep (Int .MaxValue , tags : _* )(f)
77+ }
78+
79+ def AfterStep (order : Int , tags : String * )(f : Scenario => Unit ) {
80+ afterStepHooks += new ScalaHookDefinition (f, order, tags)
81+ }
82+
83+
5084 final class Step (name : String ) {
5185 def apply (regex : String ): StepBody = new StepBody (name, regex)
5286 }
0 commit comments