Skip to content

Commit 9d1aa5e

Browse files
author
Jake Ginnivan
committed
Text reporter only flattens \r\n, changed to flatten \n too
1 parent bc22ded commit 9d1aa5e

5 files changed

Lines changed: 14 additions & 11 deletions

TestStack.BDDfy.Tests/Reporters/Html/ClassicReportBuilderTests.ShouldProduceExpectedHtmlWithExamples.approved.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ body{margin:0;padding:0;padding-bottom:40px;max-width:100%;background-color:#fff
111111
<td>negative</td>
112112
<td>is not</td>
113113
<td>
114-
<span class='canToggle' data-toggle-target='step-1-19'>Boom</span>
114+
<span class='canToggle' data-toggle-target='step-1-19'>Boom
115+
With
116+
New lines</span>
115117
<div class='step' id='step-1-19'>
116118
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs:line 113</code>
117119
</div>

TestStack.BDDfy.Tests/Reporters/Html/MetroReportBuilderTests.ShouldProduceExpectedHtmlWithExamples.approved.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abb
122122
<td>negative</td>
123123
<td>is not</td>
124124
<td>
125-
<span class='canToggle' data-toggle-target='step-1-19'>Boom</span>
125+
<span class='canToggle' data-toggle-target='step-1-19'>Boom
126+
With
127+
New lines</span>
126128
<div class='step FailedException' id='step-1-19'>
127129
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs:line 113</code>
128130
</div>

TestStack.BDDfy.Tests/Reporters/ReportTestData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private Scenario[] GetScenarios(bool includeFailingScenario, bool includeExample
110110
last.Result = Result.Failed;
111111
try
112112
{
113-
throw new InvalidOperationException("Boom");
113+
throw new InvalidOperationException("Boom\nWith\r\nNew lines");
114114
}
115115
catch (Exception ex)
116116
{

TestStack.BDDfy.Tests/Reporters/TextReporter/TextReporterTests.ShouldProduceExpectedReport.approved.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ Scenario: Example Scenario
8989
Then money <action> dispensed
9090

9191
Examples:
92-
| sign | action | Result | Errors |
93-
| positive | is | Passed | |
94-
| negative | is not | Failed | Step: Then money <action> dispensed failed with exception: [Boom] [Details at 1 below] |
92+
| sign | action | Result | Errors |
93+
| positive | is | Passed | |
94+
| negative | is not | Failed | Step: Then money <action> dispensed failed with exception: [Boom With New lines] [Details at 1 below] |
9595

9696
Exceptions:
97-
1. Boom
97+
1. Boom With New lines
9898
at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs
9999

100100

TestStack.BDDfy/Reporters/TextReporter.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,10 @@ void ReportExceptions()
211211

212212
static string FlattenExceptionMessage(string message)
213213
{
214-
return message
214+
return string.Join(" ", message
215215
.Replace("\t", " ") // replace tab with one space
216-
.Replace(Environment.NewLine, ", ") // replace new line with one space
217-
.Trim() // trim starting and trailing spaces
218-
.Replace(" ", " ")
216+
.Split(new[]{"\r\n", "\n"}, StringSplitOptions.None)
217+
.Select(s => s.Trim()))
219218
.TrimEnd(','); // chop any , from the end
220219
}
221220

0 commit comments

Comments
 (0)