Skip to content

Commit 681d69d

Browse files
committed
added TextReport tests for examples
1 parent 4a7f6de commit 681d69d

6 files changed

Lines changed: 39 additions & 51 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-3-3' >
105105
<span>Then no money is dispensed [Exception Message: 'Boom']</span>
106106
<div class='step FailedException' id='step-3-3'>
107-
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs:line 65</code>
107+
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs:line 90</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
@@ -113,7 +113,7 @@ body{margin:0;padding:0;padding-bottom:40px;max-width:100%;background-color:#fff
113113
<td>
114114
<span class='canToggle' data-toggle-target='step-1-19'>Boom</span>
115115
<div class='step' id='step-1-19'>
116-
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs:line 88</code>
116+
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs:line 113</code>
117117
</div>
118118
</td>
119119
</tr>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abb
124124
<td>
125125
<span class='canToggle' data-toggle-target='step-1-19'>Boom</span>
126126
<div class='step FailedException' id='step-1-19'>
127-
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs:line 88</code>
127+
<code> at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs:line 113</code>
128128
</div>
129129
</td>
130130
</tr>

TestStack.BDDfy.Tests/Reporters/ReportTestData.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public IEnumerable<Story> CreateMixContainingEachTypeOfOutcome()
4343
public IEnumerable<Story> CreateMixContainingEachTypeOfOutcomeWithOneScenarioPerStory()
4444
{
4545
var storyMetadata1 = new StoryMetadata(typeof(RegularAccountHolderStory), "As a person", "I want ice cream", "So that I can be happy", "Happiness");
46-
var storyMetadata2 = new StoryMetadata(typeof(GoldAccountHolderStory), "As an account holder", "I want to withdraw cash", "So that I can get money when the bank is closed", "Account holder withdraws cash");
46+
var storyMetadata2 = new StoryMetadata(typeof(GoldAccountHolderStory), "As an unhappy examples story", "I want to see failed steps", "So that I can diagnose what's wrong", "Unhappy examples");
47+
var storyMetadata3 = new StoryMetadata(typeof(PlatinumAccountHolderStory), "As a happy examples story", "I want a clean report with examples", "So that the report is clean and readable", "Happy Examples");
4748

4849
const StoryMetadata testThatReportWorksWithNoStory = null;
4950

@@ -53,14 +54,12 @@ public IEnumerable<Story> CreateMixContainingEachTypeOfOutcomeWithOneScenarioPer
5354
new Story(storyMetadata1, new Scenario(typeof(SadPathScenario), GetFailingExecutionSteps(), "Sad Path Scenario [for Happiness]")),
5455
new Story(storyMetadata1, new Scenario(typeof(SadPathScenario), GetInconclusiveExecutionSteps(), "Inconclusive Scenario [for Happiness]")),
5556
new Story(storyMetadata1, new Scenario(typeof(SadPathScenario), GetNotImplementedExecutionSteps(), "Not Implemented Scenario [for Happiness]")),
56-
new Story(storyMetadata2, new Scenario(typeof(HappyPathScenario), GetHappyExecutionSteps(), "Happy Path Scenario [for Account holder withdraws cash]")),
57-
new Story(storyMetadata2, new Scenario(typeof(SadPathScenario), GetFailingExecutionSteps(), "Sad Path Scenario [for Account holder withdraws cash]")),
58-
new Story(storyMetadata2, new Scenario(typeof(SadPathScenario), GetInconclusiveExecutionSteps(), "Inconclusive Scenario [for Account holder withdraws cash]")),
59-
new Story(storyMetadata2, new Scenario(typeof(SadPathScenario), GetNotImplementedExecutionSteps(), "Not Implemented Scenario [for Account holder withdraws cash]")),
6057
new Story(testThatReportWorksWithNoStory, new Scenario(typeof(HappyPathScenario), GetHappyExecutionSteps(), "Happy Path Scenario [with no story]")),
6158
new Story(testThatReportWorksWithNoStory, new Scenario(typeof(SadPathScenario), GetFailingExecutionSteps(), "Sad Path Scenario [with no story]")),
6259
new Story(testThatReportWorksWithNoStory, new Scenario(typeof(SadPathScenario), GetInconclusiveExecutionSteps(), "Inconclusive Scenario [with no story]")),
6360
new Story(testThatReportWorksWithNoStory, new Scenario(typeof(SadPathScenario), GetNotImplementedExecutionSteps(), "Not Implemented Scenario [with no story]")),
61+
new Story(storyMetadata2, GetScenarios(true, true)),
62+
new Story(storyMetadata3, GetScenarios(false, true)),
6463
};
6564

6665
return stories;
@@ -253,6 +252,7 @@ private void SetAllStepResults(IEnumerable<Step> steps, Result result)
253252

254253
public class RegularAccountHolderStory { }
255254
public class GoldAccountHolderStory { }
255+
public class PlatinumAccountHolderStory { }
256256
public class ExampleScenario
257257
{
258258
public void GivenA__sign__AccountBalance() { }

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

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Scenario: Sad Path Scenario [for Happiness]
2121

2222
Exceptions:
2323
1. Boom
24-
at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetFailingExecutionSteps() in c:\_mine\Code\TestStack\TestStack.BDDfy\TestStack.BDDfy.Tests\Reporters\ReportTestData.cs:line 203
24+
at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetFailingExecutionSteps() in ...\ReportTestData.cs
2525

2626

2727
Story: Happiness
@@ -46,83 +46,71 @@ Scenario: Not Implemented Scenario [for Happiness]
4646
Then no money is dispensed [Not implemented]
4747

4848

49-
Story: Account holder withdraws cash
50-
As an account holder
51-
I want to withdraw cash
52-
So that I can get money when the bank is closed
5349

54-
Scenario: Happy Path Scenario [for Account holder withdraws cash]
50+
Scenario: Happy Path Scenario [with no story]
5551
Given a positive account balance
5652
When the account holder requests money
5753
Then money is dispensed
5854

5955

60-
Story: Account holder withdraws cash
61-
As an account holder
62-
I want to withdraw cash
63-
So that I can get money when the bank is closed
6456

65-
Scenario: Sad Path Scenario [for Account holder withdraws cash]
57+
Scenario: Sad Path Scenario [with no story]
6658
Given a negative account balance [Passed]
6759
When the account holder requests money [Passed]
6860
Then no money is dispensed [Failed] [Boom] [Details at 1 below]
6961

7062
Exceptions:
7163
1. Boom
72-
at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetFailingExecutionSteps() in c:\_mine\Code\TestStack\TestStack.BDDfy\TestStack.BDDfy.Tests\Reporters\ReportTestData.cs:line 203
64+
at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetFailingExecutionSteps() in ...\ReportTestData.cs
7365

7466

75-
Story: Account holder withdraws cash
76-
As an account holder
77-
I want to withdraw cash
78-
So that I can get money when the bank is closed
7967

80-
Scenario: Inconclusive Scenario [for Account holder withdraws cash]
68+
Scenario: Inconclusive Scenario [with no story]
8169
Given a negative account balance [Passed]
8270
When the account holder requests money [Passed]
8371
Then no money is dispensed [Inconclusive]
8472

8573

86-
Story: Account holder withdraws cash
87-
As an account holder
88-
I want to withdraw cash
89-
So that I can get money when the bank is closed
9074

91-
Scenario: Not Implemented Scenario [for Account holder withdraws cash]
75+
Scenario: Not Implemented Scenario [with no story]
9276
Given a negative account balance [Passed]
9377
When the account holder requests money [Passed]
9478
Then no money is dispensed [Not implemented]
9579

9680

81+
Story: Unhappy examples
82+
As an unhappy examples story
83+
I want to see failed steps
84+
So that I can diagnose what's wrong
9785

98-
Scenario: Happy Path Scenario [with no story]
99-
Given a positive account balance
86+
Scenario: Example Scenario
87+
Given a <sign> account balance
10088
When the account holder requests money
101-
Then money is dispensed
102-
103-
89+
Then money <action> dispensed
10490

105-
Scenario: Sad Path Scenario [with no story]
106-
Given a negative account balance [Passed]
107-
When the account holder requests money [Passed]
108-
Then no money is dispensed [Failed] [Boom] [Details at 1 below]
91+
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] |
10995

11096
Exceptions:
11197
1. Boom
112-
at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetFailingExecutionSteps() in c:\_mine\Code\TestStack\TestStack.BDDfy\TestStack.BDDfy.Tests\Reporters\ReportTestData.cs:line 203
113-
114-
98+
at TestStack.BDDfy.Tests.Reporters.ReportTestData.GetScenarios(Boolean includeFailingScenario, Boolean includeExamples) in ...\ReportTestData.cs
11599

116-
Scenario: Inconclusive Scenario [with no story]
117-
Given a negative account balance [Passed]
118-
When the account holder requests money [Passed]
119-
Then no money is dispensed [Inconclusive]
120100

101+
Story: Happy Examples
102+
As a happy examples story
103+
I want a clean report with examples
104+
So that the report is clean and readable
121105

106+
Scenario: Example Scenario
107+
Given a <sign> account balance
108+
When the account holder requests money
109+
Then money <action> dispensed
122110

123-
Scenario: Not Implemented Scenario [with no story]
124-
Given a negative account balance [Passed]
125-
When the account holder requests money [Passed]
126-
Then no money is dispensed [Not implemented]
111+
Examples:
112+
| sign | action |
113+
| positive | is |
114+
| negative | is not |
127115

128116

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void ShouldProduceExpectedReport()
2323
actual.AppendLine(textReporter.ToString());
2424
}
2525

26-
Approvals.Verify(actual);
26+
Approvals.Verify(actual.ToString(), StackTraceScrubber.Scrub);
2727
}
2828
}
2929
}

0 commit comments

Comments
 (0)