Skip to content

Commit 01e21aa

Browse files
committed
Merge pull request #138 from JakeGinnivan/PrependSteps
Step type is now prepended onto step title.
2 parents e9dbc63 + e6cacb7 commit 01e21aa

File tree

10 files changed

+207
-105
lines changed

10 files changed

+207
-105
lines changed

TestStack.BDDfy.Tests/Scanner/FluentScanner/FluentWithExamples.FluentCanBeUsedWithExamples.approved.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22
Scenario: Fluent can be used with examples
3-
Given method taking <example int>
4-
Given method taking <example int>
5-
Given a different method with random arg 2
6-
Given a different method with <Prop2>
7-
When method using <example string>
8-
And I use a <Multi word heading>
9-
Then all is good
3+
Given method taking <example int>
4+
And method taking <example int>
5+
And a different method with random arg 2
6+
And a different method with <Prop2>
7+
When method using <example string>
8+
And I use a <Multi word heading>
9+
Then all is good
1010

1111
Examples:
1212
| Prop 1 | Prop2 | Prop 3 | Multi word heading |

TestStack.BDDfy.Tests/Scanner/FluentScanner/FluentWithExamples.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ public class FluentWithExamples
1313
public void FluentCanBeUsedWithExamples()
1414
{
1515
var story = this
16-
.Given(_ => GivenMethodTaking__ExampleInt__(Prop1), false)
17-
.And(_ => GivenMethodTaking__ExampleInt__(_.Prop1), false)
18-
.And(_ => GivenADifferentMethodWithRandomArg(2))
19-
.And(_ => GivenADifferentMethodWith(_prop2))
16+
.Given(_ => MethodTaking__ExampleInt__(Prop1), false)
17+
.And(_ => MethodTaking__ExampleInt__(_.Prop1), false)
18+
.And(_ => ADifferentMethodWithRandomArg(2))
19+
.And(_ => ADifferentMethodWith(_prop2))
2020
.When(_ => WhenMethodUsing__ExampleString__())
21-
.When(_ => AndIUseA(multiWordHeading))
21+
.And(_ => AndIUseA(multiWordHeading))
2222
.Then(_ => ThenAllIsGood())
2323
.WithExamples(new ExampleTable("Prop 1", "Prop2", "Prop 3", "Multi word heading")
2424
{
@@ -75,12 +75,12 @@ private void AndIUseA(string multiWordHeading)
7575
this.multiWordHeading.ShouldBeOneOf("", "val2");
7676
}
7777

78-
private void GivenADifferentMethodWith(string prop2)
78+
private void ADifferentMethodWith(string prop2)
7979
{
8080
_prop2.ShouldBeOneOf("foo", "bar");
8181
}
8282

83-
private void GivenADifferentMethodWithRandomArg(int foo)
83+
private void ADifferentMethodWithRandomArg(int foo)
8484
{
8585

8686
}
@@ -96,7 +96,7 @@ private void WhenMethodUsing__ExampleString__()
9696
Prop_3.ShouldBeOneOf(ExecutionOrder.ConsecutiveAssertion, ExecutionOrder.Initialize);
9797
}
9898

99-
private void GivenMethodTaking__ExampleInt__(int exampleInt)
99+
private void MethodTaking__ExampleInt__(int exampleInt)
100100
{
101101
exampleInt.ShouldBeInRange(1, 2);
102102
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+

2+
Scenario: Verify prepend step titles
3+
Given a step with given in it
4+
Given a step without given in it
5+
And given a step with and given in it
6+
And a step without given in it
7+
But in step
8+
But nothing in step
9+
When stuff
10+
When stuff
11+
Then we are winning
12+
Then we are winning
13+
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System.Runtime.CompilerServices;
2+
using ApprovalTests;
3+
using NUnit.Framework;
4+
using TestStack.BDDfy.Reporters;
5+
6+
namespace TestStack.BDDfy.Tests.Scanner.FluentScanner
7+
{
8+
[TestFixture]
9+
public class PrependStepTypeTests
10+
{
11+
[Test]
12+
[MethodImpl(MethodImplOptions.NoInlining)]
13+
public void VerifyPrependStepTitles()
14+
{
15+
var story = this.Given(_ => GivenAStepWithGivenInIt())
16+
.Given(_ => AStepWithoutGivenInIt())
17+
.And(_ => AndGivenAStepWithAndGivenInIt())
18+
.And(_ => AStepWithoutGivenInIt())
19+
.But(_ => ButInStep())
20+
.But(_ => NothingInStep())
21+
.When(_ => WhenStuff())
22+
.When(_ => Stuff())
23+
.Then(_ => ThenWeAreWinning())
24+
.Then(_ => WeAreWinning())
25+
.BDDfy();
26+
27+
var textReporter = new TextReporter();
28+
textReporter.Process(story);
29+
Approvals.Verify(textReporter.ToString());
30+
}
31+
32+
private void GivenAStepWithGivenInIt()
33+
{
34+
35+
}
36+
37+
private void AndGivenAStepWithAndGivenInIt()
38+
{
39+
40+
}
41+
42+
private void AStepWithoutGivenInIt()
43+
{
44+
45+
}
46+
47+
private void ButInStep()
48+
{
49+
50+
}
51+
52+
private void NothingInStep()
53+
{
54+
55+
}
56+
57+
private void WhenStuff()
58+
{
59+
60+
}
61+
62+
private void Stuff()
63+
{
64+
65+
}
66+
67+
private void ThenWeAreWinning()
68+
{
69+
70+
}
71+
72+
private void WeAreWinning()
73+
{
74+
75+
}
76+
}
77+
}

TestStack.BDDfy.Tests/Scanner/FluentScanner/WhenStepsAreScannedUsingFluentScanner.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ public void GivenSomeState_IsNotAsserting()
4545
[Test]
4646
public void GivenSomeState_StepReports()
4747
{
48-
Assert.IsTrue(GivenSomeStateStep.ShouldReport);
48+
Assert.IsTrue(GivenSomeStateStep.ShouldReport);
4949
}
5050

5151
Step WhenSomeStepUsesIncompatibleNamingConventionStep
5252
{
5353
get
5454
{
55-
return _steps.Single(s => s.Title.Trim() == "When some step uses incompatible naming convention");
55+
return _steps.Single(s => s.Title.Trim() == "And when some step uses incompatible naming convention");
5656
}
5757
}
5858

@@ -71,7 +71,7 @@ public void WhenSomeStepUsesIncompatibleNamingConvention_DoesNotAssert()
7171
[Test]
7272
public void WhenSomeStepUsesIncompatibleNamingConvention_Reports()
7373
{
74-
Assert.IsTrue(WhenSomeStepUsesIncompatibleNamingConventionStep.ShouldReport);
74+
Assert.IsTrue(WhenSomeStepUsesIncompatibleNamingConventionStep.ShouldReport);
7575
}
7676

7777
Step AndAMethodTakesArrayInputsStep
@@ -123,14 +123,14 @@ public void WhenSomethingHappensTransitionStep_DoesNotAssert()
123123
[Test]
124124
public void WhenSomethingHappensTransitionStep_Reports()
125125
{
126-
Assert.IsTrue(WhenSomethingHappensTransitionStep.ShouldReport);
126+
Assert.IsTrue(WhenSomethingHappensTransitionStep.ShouldReport);
127127
}
128128

129129
Step WhenSomethingHappensTransitionStepIgnoringInputInStepTitle
130130
{
131131
get
132132
{
133-
return _steps.Single(s => s.Title == "When something happens");
133+
return _steps.Single(s => s.Title == "And when something happens");
134134
}
135135
}
136136

@@ -149,7 +149,7 @@ public void WhenSomethingHappensTransitionStepIgnoringInputInStepTitle_DoesNotAs
149149
[Test]
150150
public void WhenSomethingHappensTransitionStepIgnoringInputInStepTitle_Reports()
151151
{
152-
Assert.IsTrue(WhenSomethingHappensTransitionStepIgnoringInputInStepTitle.ShouldReport);
152+
Assert.IsTrue(WhenSomethingHappensTransitionStepIgnoringInputInStepTitle.ShouldReport);
153153
}
154154

155155
Step WhenSomethingHappensConsecutiveTransitionStep
@@ -175,7 +175,7 @@ public void WhenSomethingHappensConsecutiveTransitionStep_DoesNotAssert()
175175
[Test]
176176
public void WhenSomethingHappensConsecutiveTransitionStep_Reports()
177177
{
178-
Assert.IsTrue(WhenSomethingHappensConsecutiveTransitionStep.ShouldReport);
178+
Assert.IsTrue(WhenSomethingHappensConsecutiveTransitionStep.ShouldReport);
179179
}
180180

181181
Step AndThenSomethingElseHappensStep
@@ -201,7 +201,7 @@ public void AndThenSomethingElseHappensStep_DoesNotAssert()
201201
[Test]
202202
public void AndThenSomethingElseHappensStep_Reports()
203203
{
204-
Assert.IsTrue(AndThenSomethingElseHappensStep.ShouldReport);
204+
Assert.IsTrue(AndThenSomethingElseHappensStep.ShouldReport);
205205
}
206206

207207
Step ThenTheFollowingAssertionsShouldBeCorrectStep
@@ -253,7 +253,7 @@ public void AndIncorrectAttributeWouldNotMatterStep_DoesAssert()
253253
[Test]
254254
public void AndIncorrectAttributeWouldNotMatterStep_Reports()
255255
{
256-
Assert.IsTrue(AndIncorrectAttributeWouldNotMatterStep.ShouldReport);
256+
Assert.IsTrue(AndIncorrectAttributeWouldNotMatterStep.ShouldReport);
257257
}
258258

259259
Step AndInputsAreFormattedPropertlyInTheTitle
@@ -297,7 +297,7 @@ public void TearDownStep_DoesAssert()
297297
[Test]
298298
public void TearDownStep_DoesNotReports()
299299
{
300-
Assert.IsFalse(TearDownStep.ShouldReport);
300+
Assert.IsFalse(TearDownStep.ShouldReport);
301301
}
302302
}
303303
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
<Compile Include="Scanner\FluentScanner\FluentWithExamples.cs" />
9292
<Compile Include="Scanner\FluentScanner\InlineAssertions.cs" />
9393
<Compile Include="Scanner\FluentScanner\StepTitleTests.cs" />
94+
<Compile Include="Scanner\FluentScanner\PrependStepTypeTests.cs" />
9495
<Compile Include="Scanner\ReflectiveScanner\ReflectiveWithExamples.cs" />
9596
<Compile Include="Scanner\StepScanners\Examples\ExampleTableTests.cs" />
9697
<Compile Include="Scanner\StepScanners\Examples\ExampleValueTests.cs" />

TestStack.BDDfy/Reporters/Html/Scripts/classic.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ li {
3333
background: -o-linear-gradient(top, #679bdb 1%,#3b77a5 100%);
3434
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#679bdb), color-stop(100%,#3b77a5));
3535
background: -webkit-linear-gradient(top, #679bdb 1%,#3b77a5 100%);
36+
/* ReSharper disable once InvalidValue */
3637
background: linear-gradient(top, #679bdb 1%,#3b77a5 100%);
3738
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#679bdb', endColorstr='#3b77a5',GradientType=0 );
3839
/* Chrome,Safari4+ */

0 commit comments

Comments
 (0)