Skip to content

Commit 35cc5c0

Browse files
committed
changed test to always have same stacktrace to match approval tests html file
1 parent 20a0fdf commit 35cc5c0

2 files changed

Lines changed: 19 additions & 20 deletions

File tree

TestStack.BDDfy.Tests/Reporters/HtmlMetro/HtmlMetroReportBuilderTests.ShouldProduceExpectedHtml.approved.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@
145145
<span>When the account holder requests money</span>
146146
</li>
147147
<li class='step Failed Assertion canToggle' data-toggle-target='step-6-3' >
148-
<span>Then no money is dispensed [Exception Message: 'This is a test exception, it should be shown when step is expanded.']</span>
148+
<span>Then no money is dispensed [Exception Message: 'This is a test exception.']</span>
149149
<div class='step FailedException' id='step-6-3'>
150-
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.MakeExWithStackTrace() in c:\dev\Community\Teststack\bddfy\TestStack.BDDfy\TestStack.BDDfy.Tests\Reporters\ReportTestData.cs:line 74</code>
150+
<code>This is a test stack trace</code>
151151
</div>
152152
</li>
153153
</ul>
@@ -215,9 +215,9 @@
215215
<span>When the account holder requests money</span>
216216
</li>
217217
<li class='step Failed Assertion canToggle' data-toggle-target='step-2-3' >
218-
<span>Then no money is dispensed [Exception Message: 'This is a test exception, it should be shown when step is expanded.']</span>
218+
<span>Then no money is dispensed [Exception Message: 'This is a test exception.']</span>
219219
<div class='step FailedException' id='step-2-3'>
220-
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.MakeExWithStackTrace() in c:\dev\Community\Teststack\bddfy\TestStack.BDDfy\TestStack.BDDfy.Tests\Reporters\ReportTestData.cs:line 74</code>
220+
<code>This is a test stack trace</code>
221221
</div>
222222
</li>
223223
</ul>
@@ -280,9 +280,9 @@
280280
<span>When the account holder requests money</span>
281281
</li>
282282
<li class='step Failed Assertion canToggle' data-toggle-target='step-10-3' >
283-
<span>Then no money is dispensed [Exception Message: 'This is a test exception, it should be shown when step is expanded.']</span>
283+
<span>Then no money is dispensed [Exception Message: 'This is a test exception.']</span>
284284
<div class='step FailedException' id='step-10-3'>
285-
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.MakeExWithStackTrace() in c:\dev\Community\Teststack\bddfy\TestStack.BDDfy\TestStack.BDDfy.Tests\Reporters\ReportTestData.cs:line 74</code>
285+
<code>This is a test stack trace</code>
286286
</div>
287287
</li>
288288
</ul>

TestStack.BDDfy.Tests/Reporters/ReportTestData.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,11 @@ private Scenario[] GetOneOfEachScenarioResult()
6161

6262
SetAllStepResults(scenarios[1].Steps, Result.Passed);
6363
scenarios[1].Steps.Last().Result = Result.Failed;
64-
scenarios[1].Steps.Last().Exception = MakeExWithStackTrace();
65-
64+
scenarios[1].Steps.Last().Exception = new FakeExceptionWithStackTrace("This is a test exception.");
6665

6766
return scenarios.ToArray();
6867
}
6968

70-
private Exception MakeExWithStackTrace()
71-
{
72-
try
73-
{
74-
throw new NotImplementedException("This is a test exception, it should be shown when step is expanded.");
75-
}
76-
catch (Exception ex)
77-
{
78-
return ex;
79-
}
80-
}
81-
8269
private IEnumerable<Step> GetHappyExecutionSteps()
8370
{
8471
var steps = new List<Step>()
@@ -156,5 +143,17 @@ public void GivenANegativeAccountBalance() { }
156143
public void WhenTheAccountHolderRequestsMoney() { }
157144
public void ThenNoMoneyIsDispensed() { }
158145
}
146+
147+
class FakeExceptionWithStackTrace : Exception
148+
{
149+
public FakeExceptionWithStackTrace(string message)
150+
: base(message)
151+
{ }
152+
153+
public override string StackTrace
154+
{
155+
get { return "This is a test stack trace"; }
156+
}
157+
}
159158
}
160159
}

0 commit comments

Comments
 (0)