@@ -16,9 +16,11 @@ public void Process(Story story)
16
16
{
17
17
ReportStoryHeader ( story ) ;
18
18
19
- var allSteps = story . Scenarios . SelectMany ( s => s . Steps ) . ToList ( ) ;
19
+ var allSteps = story . Scenarios . SelectMany ( s => s . Steps )
20
+ . Select ( GetStepWithLines )
21
+ . ToList ( ) ;
20
22
if ( allSteps . Any ( ) )
21
- _longestStepSentence = allSteps . Max ( s => PrefixWithSpaceIfRequired ( s ) . Length ) ;
23
+ _longestStepSentence = allSteps . SelectMany ( s => s . Item2 . Select ( l => l . Length ) ) . Max ( ) ;
22
24
23
25
foreach ( var scenarioGroup in story . Scenarios . GroupBy ( s => s . Id ) )
24
26
{
@@ -31,7 +33,7 @@ public void Process(Story story)
31
33
if ( exampleScenario . Steps . Any ( ) )
32
34
{
33
35
foreach ( var step in exampleScenario . Steps . Where ( s => s . ShouldReport ) )
34
- ReportOnStep ( exampleScenario , step , false ) ;
36
+ ReportOnStep ( exampleScenario , GetStepWithLines ( step ) , false ) ;
35
37
}
36
38
37
39
WriteLine ( ) ;
@@ -47,7 +49,7 @@ public void Process(Story story)
47
49
if ( scenario . Steps . Any ( ) )
48
50
{
49
51
foreach ( var step in scenario . Steps . Where ( s => s . ShouldReport ) )
50
- ReportOnStep ( scenario , step , true ) ;
52
+ ReportOnStep ( scenario , GetStepWithLines ( step ) , true ) ;
51
53
}
52
54
}
53
55
@@ -59,6 +61,11 @@ public void Process(Story story)
59
61
ReportExceptions ( ) ;
60
62
}
61
63
64
+ private static Tuple < Step , string [ ] > GetStepWithLines ( Step s )
65
+ {
66
+ return Tuple . Create ( s , s . Title . Replace ( "\r \n " , "\n " ) . Split ( '\n ' ) . Select ( l => PrefixWithSpaceIfRequired ( l , s . ExecutionOrder ) ) . ToArray ( ) ) ;
67
+ }
68
+
62
69
private void ReportTags ( List < string > tags )
63
70
{
64
71
if ( ! tags . Any ( ) )
@@ -141,36 +148,43 @@ private void ReportStoryHeader(Story story)
141
148
WriteLine ( "\t " + story . Metadata . Narrative3 ) ;
142
149
}
143
150
144
- static string PrefixWithSpaceIfRequired ( Step step )
151
+ static string PrefixWithSpaceIfRequired ( string stepTitle , ExecutionOrder executionOrder )
145
152
{
146
- var stepTitle = step . Title ;
147
- var executionOrder = step . ExecutionOrder ;
148
-
149
153
if ( executionOrder == ExecutionOrder . ConsecutiveAssertion ||
150
154
executionOrder == ExecutionOrder . ConsecutiveSetupState ||
151
155
executionOrder == ExecutionOrder . ConsecutiveTransition )
152
156
stepTitle = " " + stepTitle ; // add two spaces in the front for indentation.
153
157
154
- return stepTitle . Replace ( Environment . NewLine , Environment . NewLine + " \t \t " ) ;
158
+ return stepTitle ;
155
159
}
156
160
157
- void ReportOnStep ( Scenario scenario , Step step , bool includeResults )
161
+ void ReportOnStep ( Scenario scenario , Tuple < Step , string [ ] > stepAndLines , bool includeResults )
158
162
{
159
163
if ( ! includeResults )
160
164
{
161
- WriteLine ( "\t {0}" , PrefixWithSpaceIfRequired ( step ) . PadRight ( _longestStepSentence ) ) ;
165
+ foreach ( var line in stepAndLines . Item2 )
166
+ {
167
+ WriteLine ( "\t {0}" , line ) ;
168
+ }
162
169
return ;
163
170
}
164
171
165
- var message =
166
- string . Format
167
- ( "\t {0} [{1}] " ,
168
- PrefixWithSpaceIfRequired ( step ) . PadRight ( _longestStepSentence + 5 ) ,
169
- Configurator . Scanners . Humanize ( step . Result . ToString ( ) ) ) ;
172
+ var step = stepAndLines . Item1 ;
173
+ var humanizedResult = Configurator . Scanners . Humanize ( step . Result . ToString ( ) ) ;
170
174
171
- // if all the steps have passed, there is no reason to make noise
175
+ string message ;
172
176
if ( scenario . Result == Result . Passed )
173
- message = "\t " + PrefixWithSpaceIfRequired ( step ) ;
177
+ message = string . Format ( "\t {0}" , stepAndLines . Item2 [ 0 ] ) ;
178
+ else
179
+ {
180
+ var paddedFirstLine = stepAndLines . Item2 [ 0 ] . PadRight ( _longestStepSentence + 5 ) ;
181
+ message = string . Format ( "\t {0} [{1}] " , paddedFirstLine , humanizedResult ) ;
182
+ }
183
+
184
+ if ( stepAndLines . Item2 . Length > 1 )
185
+ {
186
+ message = string . Format ( "{0}\r \n {1}" , message , string . Join ( "\r \n " , stepAndLines . Item2 . Skip ( 1 ) ) ) ;
187
+ }
174
188
175
189
if ( step . Exception != null )
176
190
message += CreateExceptionMessage ( step ) ;
@@ -226,7 +240,7 @@ static string FlattenExceptionMessage(string message)
226
240
{
227
241
return string . Join ( " " , message
228
242
. Replace ( "\t " , " " ) // replace tab with one space
229
- . Split ( new [ ] { "\r \n " , "\n " } , StringSplitOptions . None )
243
+ . Split ( new [ ] { "\r \n " , "\n " } , StringSplitOptions . None )
230
244
. Select ( s => s . Trim ( ) ) )
231
245
. TrimEnd ( ',' ) ; // chop any , from the end
232
246
}
0 commit comments