Permalink
Browse files

Feature scenario setup support

Add support for scenario_setup functions that is run at the beginning of
each scenario.
  • Loading branch information...
1 parent 7b2ec5d commit c65b27d6b399f8f99f969f04d927cae371d2d83c Knut O. Hellan committed Mar 6, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/cucumberl.erl
View
@@ -95,9 +95,11 @@ process_line({Type, LineNum, Tokens, Line},
{_, feature} ->
{false, {ok, State}, Stats};
{_, scenario} ->
+ call_scenario_setup(FeatureModule),
{false, {ok, State},
Stats#cucumberl_stats{scenarios = NScenarios + 1}};
{_, scenario_outline} ->
+ call_scenario_setup(FeatureModule),
{false, {ok, State},
Stats#cucumberl_stats{scenarios = NScenarios + 1}};
{false, {action, G}} ->
@@ -191,3 +193,11 @@ call_teardown(FeatureModule, State) ->
false ->
undefined
end.
+
+call_scenario_setup(FeatureModule) ->
+ case erlang:function_exported(FeatureModule, scenario_setup, 0) of
+ true ->
+ FeatureModule:scenario_setup();
+ false ->
+ undefined
+ end.

0 comments on commit c65b27d

Please sign in to comment.