Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

I have fixed two bugs #11

Closed
wants to merge 8 commits into from

1 participant

Knut O. Hellan
Knut O. Hellan

The first one was the check for existence of teardown/0 and calling teardown/1. I changed the check to look for teardown/1 since we want the State variable.
The second was a correction of the typo cucumber_parser to cucumberl_parser

added some commits October 03, 2011
Fixed teardown bug
The test for teardown looked for teardown/0, but attempted to call
teardown/1. This fix looks for teardown/1 as well
b9e2721
Bugfix typo
Attempted to call a function in cucumber_parser. Corrected this to 
cucuberl_parser.
331e7b7
Color coding output
Red for indicating failure
Green for indicating normal
983c509
Knut O. Hellan

I also added color coding to the output in a thrift commit. I like having color coded output and missed this so I added it

added some commits October 12, 2011
Ignoring test tmp dir and vi swp-files 7b2ec5d
Feature scenario setup support
Add support for scenario_setup functions that is run at the beginning of
each scenario.
c65b27d
Merge branch 'membase_original' into head_merge 60d43c4
Add colorization
Add red color to the not implemented message
321d6a6
Bugfix set default text color at the end a15244e
Knut O. Hellan khellan closed this March 06, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 8 unique commits by 1 author.

Oct 03, 2011
Fixed teardown bug
The test for teardown looked for teardown/0, but attempted to call
teardown/1. This fix looks for teardown/1 as well
b9e2721
Bugfix typo
Attempted to call a function in cucumber_parser. Corrected this to 
cucuberl_parser.
331e7b7
Color coding output
Red for indicating failure
Green for indicating normal
983c509
Oct 12, 2011
Ignoring test tmp dir and vi swp-files 7b2ec5d
Mar 06, 2012
Feature scenario setup support
Add support for scenario_setup functions that is run at the beginning of
each scenario.
c65b27d
Merge branch 'membase_original' into head_merge 60d43c4
Add colorization
Add red color to the not implemented message
321d6a6
Bugfix set default text color at the end a15244e
This page is out of date. Refresh to see the latest.
4  .gitignore
@@ -2,4 +2,6 @@ ebin
2 2
 erl_crash.dump
3 3
 **.cov.html
4 4
 *~
5  
-cucumberl
  5
+cucumberl
  6
+.eunit
  7
+*.swp
41  src/cucumberl.erl
@@ -30,7 +30,7 @@ run(FilePath)
30 30
 
31 31
 run(FilePath, FeatureModule)
32 32
   when is_list(FilePath), is_atom(FeatureModule) ->
33  
-    {_, Tree} = cucumber_parser:parse(FilePath),
  33
+    {_, Tree} = cucumberl_parser:parse(FilePath),
34 34
     run_tree(Tree, FeatureModule).
35 35
 
36 36
 run_tree(Tree, FeatureModule) ->
@@ -54,12 +54,12 @@ run_tree(Tree, FeatureModule) ->
54 54
         catch
55 55
             Err:Reason ->
56 56
                 %% something else went wrong, which means fail
57  
-                io:format("Feature Failed: ~p:~p ~p",
  57
+                io:format("\e[31mFeature Failed: ~p:~p ~p",
58 58
                           [Err, Reason,
59 59
                            erlang:get_stacktrace()]),
60 60
                 failed
61 61
         end,
62  
-    case Result of
  62
+    Verdict = case Result of
63 63
         #cucumberl_stats{scenarios = NScenarios,
64 64
                          steps = NSteps,
65 65
                          failures = []}  ->
@@ -69,12 +69,15 @@ run_tree(Tree, FeatureModule) ->
69 69
         #cucumberl_stats{scenarios = NScenarios,
70 70
                          steps = NSteps,
71 71
                          failures = Failures}  ->
72  
-            io:format("~n~p scenarios~n~p steps~n~p failures ~n~n",
  72
+            io:format("~n~p scenarios~n~p steps~n\e[31m~p failures ~n~n",
73 73
                       [NScenarios, NSteps, erlang:length(Failures)]),
74 74
             {failed, Result};
75 75
         _ ->
76 76
             failed
77  
-    end.
  77
+    end,
  78
+    io:format("\e[39m"),
  79
+    Verdict.
  80
+
78 81
 
79 82
 process_line({Type, LineNum, Tokens, Line},
80 83
              {SkipScenario, State,
@@ -84,7 +87,7 @@ process_line({Type, LineNum, Tokens, Line},
84 87
              FeatureModule) ->
85 88
     %% GWT stands for given-when-then.
86 89
     %% GWT is the previous line's given-when-then atom.
87  
-    io:format("~s:~s ~n",
  90
+    io:format("\e[32m~s:~s ~n",
88 91
               [string:left(Line, 65),
89 92
                string:left(integer_to_list(LineNum), 4)]),
90 93
 
@@ -95,9 +98,11 @@ process_line({Type, LineNum, Tokens, Line},
95 98
             {_, feature} ->
96 99
                 {false, {ok, State}, Stats};
97 100
             {_, scenario} ->
  101
+                call_scenario_setup(FeatureModule),
98 102
                 {false, {ok, State},
99 103
                  Stats#cucumberl_stats{scenarios = NScenarios + 1}};
100 104
             {_, scenario_outline} ->
  105
+                call_scenario_setup(FeatureModule),
101 106
                 {false, {ok, State},
102 107
                  Stats#cucumberl_stats{scenarios = NScenarios + 1}};
103 108
             {false, {action, G}} ->
@@ -107,11 +112,11 @@ process_line({Type, LineNum, Tokens, Line},
107 112
                     catch
108 113
                         error:function_clause ->
109 114
                             %% we don't have a matching function clause
110  
-                            io:format("~nSTEP ~s is *not* implemented: ~p ~n",
  115
+                            io:format("~n\e[31mSTEP ~s is *not* implemented: ~p ~n",
111 116
                                       [Line, Tokens]),
112 117
                             {failed, {unimplemented, Tokens}};
113 118
                         Err:Reason ->
114  
-                            io:format("~nSTEP: ~s FAILED: ~n ~p:~p ~p~n",
  119
+                            io:format("~n\e[31mSTEP: ~s FAILED: ~n ~p:~p ~p~n",
115 120
                                       [Line, Err, Reason,
116 121
                                        erlang:get_stacktrace()]),
117 122
                             %% something else went wrong, which means fail
@@ -136,14 +141,14 @@ process_line({Type, LineNum, Tokens, Line},
136 141
                 skipped ->
137 142
                     {SkipScenario2, State, Stats2};
138 143
                 missing ->
139  
-                    io:format("---------NO-STEP--------~n~n"),
140  
-                    io:format("a step definition snippet...~n"),
  144
+                    io:format("\e[31m---------NO-STEP--------~n~n"),
  145
+                    io:format("\e[31ma step definition snippet...~n"),
141 146
                     format_missing_step(G1, Tokens),
142 147
                     {true, undefined, undefined, State,
143 148
                      Stats2#cucumberl_stats{failures = [{missing, G1}
144 149
                                                         | FailedSoFar] }};
145 150
                 FailedResult ->
146  
-                    io:format("-------FAIL------- ~n~n"),
  151
+                    io:format("\e[31m-------FAIL------- ~n~n"),
147 152
                     {true, State,
148 153
                      Stats2#cucumberl_stats{ failures = [{FailedResult, Result}
149 154
                                                          |FailedSoFar] }}
@@ -174,9 +179,9 @@ check_step({failed, _})    -> failed;
174 179
 check_step(_)              -> invalid_result.
175 180
 
176 181
 format_missing_step('when', Tokens) ->
177  
-    io:format("'when'(~p, State, _) ->~n  undefined.~n~n", [Tokens]);
  182
+    io:format("\e[31m'when'(~p, State, _) ->~n  undefined.~n~n", [Tokens]);
178 183
 format_missing_step(GWT, Tokens) ->
179  
-    io:format("~p(~p, State, _) ->~n  undefined.~n~n", [GWT, Tokens]).
  184
+    io:format("\e[31m~p(~p, State, _) ->~n  undefined.~n~n", [GWT, Tokens]).
180 185
 
181 186
 call_setup(FeatureModule) ->
182 187
     case erlang:function_exported(FeatureModule, setup, 0) of
@@ -187,9 +192,17 @@ call_setup(FeatureModule) ->
187 192
     end.
188 193
 
189 194
 call_teardown(FeatureModule, State) ->
190  
-    case erlang:function_exported(FeatureModule, teardown, 0) of
  195
+    case erlang:function_exported(FeatureModule, teardown, 1) of
191 196
         true ->
192 197
             FeatureModule:teardown(State);
193 198
         false ->
194 199
             undefined
195 200
     end.
  201
+
  202
+call_scenario_setup(FeatureModule) ->
  203
+    case erlang:function_exported(FeatureModule, scenario_setup, 0) of
  204
+        true ->
  205
+            FeatureModule:scenario_setup();
  206
+        false ->
  207
+            undefined
  208
+    end.
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.