Skip to content

Commit 34dd87e

Browse files
author
Jake Ginnivan
committed
Exposed tags in Text Reporter
1 parent b12f228 commit 34dd87e

6 files changed

Lines changed: 50 additions & 3 deletions

File tree

TestStack.BDDfy.Tests/Processors/TestRunnerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class TestRunnerTests
1515
public void InitialisesScenarioWithExampleBeforeRunning()
1616
{
1717
const int expectedValue = 1;
18-
int actualValue = 0;
18+
var actualValue = 0;
1919
var exampleTable = new ExampleTable("ExampleValue")
2020
{
2121
expectedValue

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Runtime.CompilerServices;
1+
using System.Runtime.CompilerServices;
32
using System.Text;
43
using ApprovalTests;
54
using NUnit.Framework;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+

2+
Scenario: Tags are reported in text report
3+
Given a step
4+
5+
Tags: Tag1, Tag 2
6+

TestStack.BDDfy.Tests/TagsTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using ApprovalTests;
2+
using NUnit.Framework;
3+
using TestStack.BDDfy.Reporters;
4+
5+
namespace TestStack.BDDfy.Tests
6+
{
7+
[TestFixture]
8+
public class TagsTests
9+
{
10+
[Test]
11+
public void TagsAreReportedInTextReport()
12+
{
13+
var story = this.Given(_ => GivenAStep())
14+
.WithTags("Tag1", "Tag 2")
15+
.BDDfy();
16+
17+
var textReporter = new TextReporter();
18+
textReporter.Process(story);
19+
20+
Approvals.Verify(textReporter.ToString());
21+
}
22+
23+
private void GivenAStep()
24+
{
25+
26+
}
27+
}
28+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
<Compile Include="Scanner\WhenTestClassUsesExecutableAttributes.cs" />
152152
<Compile Include="Stories\StoryClassAndScenarioClassAreTheSame.cs" />
153153
<Compile Include="Stories\StorySubclass.cs" />
154+
<Compile Include="TagsTests.cs" />
154155
<Compile Include="UnusedExampleValueScenario.cs" />
155156
<Compile Include="WhenAnEmptyScenarioIsBddified.cs" />
156157
<Compile Include="WhenAnEmptyStoryIsBddified.cs" />

TestStack.BDDfy/Reporters/TextReporter.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public void Process(Story story)
3636

3737
WriteLine();
3838
WriteExamples(exampleScenario, scenarioGroup);
39+
ReportTags(exampleScenario.Tags);
3940
}
4041
else
4142
{
@@ -49,12 +50,24 @@ public void Process(Story story)
4950
ReportOnStep(scenario, step, true);
5051
}
5152
}
53+
54+
var exampleScenario = story.Scenarios.First();
55+
ReportTags(exampleScenario.Tags);
5256
}
5357
}
5458

5559
ReportExceptions();
5660
}
5761

62+
private void ReportTags(List<string> tags)
63+
{
64+
if (!tags.Any())
65+
return;
66+
67+
WriteLine();
68+
WriteLine("Tags: {0}", string.Join(", ", tags));
69+
}
70+
5871
private void WriteExamples(Scenario exampleScenario, IEnumerable<Scenario> scenarioGroup)
5972
{
6073
WriteLine("Examples: ");

0 commit comments

Comments
 (0)