Skip to content

Commit c54b23d

Browse files
author
Jake Ginnivan
committed
Fixing markdown report too
1 parent 9d1aa5e commit c54b23d

5 files changed

Lines changed: 13 additions & 14 deletions

File tree

TestStack.BDDfy.Tests/Reporters/MarkDown/MarkDownReportBuilderTests.ShouldProduceExpectedMarkdownWithExamples.approved.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
### Examples:
1212

13-
| sign | action | Result | Errors |
14-
| positive | is | Passed | |
15-
| negative | is not | Failed | Step: Then money <action> dispensed failed with exception: [Boom] [Details at 1 below] |
13+
| sign | action | Result | Errors |
14+
| positive | is | Passed | |
15+
| negative | is not | Failed | Step: Then money <action> dispensed failed with exception: [Boom With New lines] [Details at 1 below] |
1616

1717
#### Exceptions:
18-
1. Boom
18+
1. Boom With New lines
1919
at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs:line 113
2020

2121
## Story: Happiness

TestStack.BDDfy.Tests/Reporters/TextReporter/TextReporterTests.ShouldProduceExpectedMarkdownWithExamples.approved.txt renamed to TestStack.BDDfy.Tests/Reporters/TextReporter/TextReporterTests.ShouldProduceExpectedTextWithExamples.approved.txt

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

2727
Examples:
28-
| sign | action | Result | Errors |
29-
| positive | is | Passed | |
30-
| negative | is not | Failed | Step: Then money <action> dispensed failed with exception: [Boom] [Details at 1 below] |
28+
| sign | action | Result | Errors |
29+
| positive | is | Passed | |
30+
| negative | is not | Failed | Step: Then money <action> dispensed failed with exception: [Boom With New lines] [Details at 1 below] |
3131

3232
Exceptions:
33-
1. Boom
33+
1. Boom With New lines
3434
at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs
3535

3636

TestStack.BDDfy.Tests/Reporters/TextReporter/TextReporterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void ShouldProduceExpectedReport()
2929

3030
[Test]
3131
[MethodImpl(MethodImplOptions.NoInlining)]
32-
public void ShouldProduceExpectedMarkdownWithExamples()
32+
public void ShouldProduceExpectedTextWithExamples()
3333
{
3434
var stories = new ReportTestData().CreateTwoStoriesEachWithOneFailingScenarioAndOnePassingScenarioWithThreeStepsOfFiveMillisecondsAndEachHasTwoExamples();
3535
var actual = new StringBuilder();

TestStack.BDDfy.Tests/TestStack.BDDfy.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
<Content Include="Reporters\Html\MetroReportBuilderTests.ShouldProduceExpectedHtmlWithExamples.approved.txt" />
176176
<Content Include="Reporters\MarkDown\MarkDownReportBuilderTests.ShouldProduceExpectedMarkdown.approved.txt" />
177177
<Content Include="Reporters\MarkDown\MarkDownReportBuilderTests.ShouldProduceExpectedMarkdownWithExamples.approved.txt" />
178-
<Content Include="Reporters\TextReporter\TextReporterTests.ShouldProduceExpectedMarkdownWithExamples.approved.txt" />
178+
<Content Include="Reporters\TextReporter\TextReporterTests.ShouldProduceExpectedTextWithExamples.approved.txt" />
179179
<Content Include="Reporters\TextReporter\TextReporterTests.ShouldProduceExpectedReport.approved.txt" />
180180
</ItemGroup>
181181
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

TestStack.BDDfy/Reporters/MarkDown/MarkDownReportBuilder.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,10 @@ void ReportExceptions(StringBuilder report)
171171

172172
static string FlattenExceptionMessage(string message)
173173
{
174-
return message
174+
return string.Join(" ", message
175175
.Replace("\t", " ") // replace tab with one space
176-
.Replace(Environment.NewLine, ", ") // replace new line with one space
177-
.Trim() // trim starting and trailing spaces
178-
.Replace(" ", " ")
176+
.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None)
177+
.Select(s => s.Trim()))
179178
.TrimEnd(','); // chop any , from the end
180179
}
181180
}

0 commit comments

Comments
 (0)