Skip to content

Commit cff0a51

Browse files
committed
Merge pull request #142 from JakeGinnivan/MetroReportUsingStackTraceScrubber
Switched MetroReport to use the stack trace scrubber like the classic re...
2 parents 1563093 + 8c186ce commit cff0a51

8 files changed

Lines changed: 22 additions & 26 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ body{margin:0;padding:0;padding-bottom:40px;max-width:100%;background-color:#fff
104104
<li class='step Failed Assertion canToggle' data-toggle-target='step-1-1' >
105105
<span>Then no money is dispensed [Exception Message: 'Boom']</span>
106106
<div class='step FailedException' id='step-1-1'>
107-
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs:line 89</code>
107+
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs</code>
108108
</div>
109109
</li>
110110
</ul>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ body{margin:0;padding:0;padding-bottom:40px;max-width:100%;background-color:#fff
115115
With
116116
New lines</span>
117117
<div class='step' id='step-1-1'>
118-
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs:line 112</code>
118+
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs</code>
119119
</div>
120120
</td>
121121
</tr>

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abb
141141
<span>When the account holder requests money</span>
142142
</li>
143143
<li class='step Failed Assertion canToggle' data-toggle-target='step-1-1' >
144-
<span>Then no money is dispensed [Exception Message: 'This is a test exception.']</span>
144+
<span>Then no money is dispensed [Exception Message: 'Boom']</span>
145145
<div class='step FailedException' id='step-1-1'>
146-
<code>This is a test stack trace</code>
146+
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetOneOfEachScenarioResult() in ...\ReportTestData.cs</code>
147147
</div>
148148
</li>
149149
</ul>
@@ -214,9 +214,9 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abb
214214
<span>When the account holder requests money</span>
215215
</li>
216216
<li class='step Failed Assertion canToggle' data-toggle-target='step-1-1' >
217-
<span>Then no money is dispensed [Exception Message: 'This is a test exception.']</span>
217+
<span>Then no money is dispensed [Exception Message: 'Boom']</span>
218218
<div class='step FailedException' id='step-1-1'>
219-
<code>This is a test stack trace</code>
219+
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetOneOfEachScenarioResult() in ...\ReportTestData.cs</code>
220220
</div>
221221
</li>
222222
</ul>
@@ -282,9 +282,9 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abb
282282
<span>When the account holder requests money</span>
283283
</li>
284284
<li class='step Failed Assertion canToggle' data-toggle-target='step-1-1' >
285-
<span>Then no money is dispensed [Exception Message: 'This is a test exception.']</span>
285+
<span>Then no money is dispensed [Exception Message: 'Boom']</span>
286286
<div class='step FailedException' id='step-1-1'>
287-
<code>This is a test stack trace</code>
287+
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetOneOfEachScenarioResult() in ...\ReportTestData.cs</code>
288288
</div>
289289
</li>
290290
</ul>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abb
126126
With
127127
New lines</span>
128128
<div class='step FailedException' id='step-1-1'>
129-
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs:line 112</code>
129+
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs</code>
130130
</div>
131131
</td>
132132
</tr>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

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

2121
## Story: Happiness
2222
**As a person**

TestStack.BDDfy.Tests/Reporters/ReportApprover.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static void Approve(Func<FileReportModel> model, IReportBuilder reportBui
1414
using (new TemporaryCulture("en-GB"))
1515
{
1616
var result = reportBuilder.CreateReport(model());
17-
Approvals.Verify(result, s => Scrub(StackTraceScrubber.ScrubPaths(s)));
17+
Approvals.Verify(result, s => Scrub(StackTraceScrubber.ScrubLineNumbers(StackTraceScrubber.ScrubPaths(s))));
1818
}
1919
}
2020

TestStack.BDDfy.Tests/Reporters/ReportTestData.cs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,16 @@ private Scenario[] GetOneOfEachScenarioResult()
144144
SetAllStepResults(scenarios[0].Steps, Result.Passed);
145145

146146
SetAllStepResults(scenarios[1].Steps, Result.Passed);
147-
scenarios[1].Steps.Last().Result = Result.Failed;
148-
scenarios[1].Steps.Last().Exception = new FakeExceptionWithStackTrace("This is a test exception.");
147+
var last = scenarios[1].Steps.Last();
148+
last.Result = Result.Failed;
149+
try
150+
{
151+
throw new InvalidOperationException("Boom");
152+
}
153+
catch (Exception ex)
154+
{
155+
last.Exception = ex;
156+
}
149157

150158
return scenarios.ToArray();
151159
}
@@ -270,17 +278,5 @@ public void GivenANegativeAccountBalance() { }
270278
public void WhenTheAccountHolderRequestsMoney() { }
271279
public void ThenNoMoneyIsDispensed() { }
272280
}
273-
274-
class FakeExceptionWithStackTrace : Exception
275-
{
276-
public FakeExceptionWithStackTrace(string message)
277-
: base(message)
278-
{ }
279-
280-
public override string StackTrace
281-
{
282-
get { return "This is a test stack trace"; }
283-
}
284-
}
285281
}
286282
}

TestStack.BDDfy/Reporters/MarkDown/MarkDownReportBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public string CreateReport(FileReportModel model)
5454
{
5555
report.AppendLine(string.Format("### {0}", scenario.Title));
5656

57-
foreach (var step in scenario.Steps)
57+
foreach (var step in scenario.Steps.Where(s => s.ShouldReport))
5858
report.AppendLine(" " + HttpUtility.HtmlEncode(step.Title) + " ");
5959

6060
report.AppendLine(); // separator

0 commit comments

Comments
 (0)