Skip to content

Commit df0ad68

Browse files
committed
Merge pull request #42 from MehdiK/fixing-null-error
Fixes #41 - html report failing when there's no story
2 parents 5dc0abb + 54b380d commit df0ad68

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using NUnit.Framework;
2+
3+
namespace TestStack.BDDfy.Samples
4+
{
5+
public class CanWorkWithoutAStory
6+
{
7+
public void Given_no_story_is_provided()
8+
{
9+
}
10+
11+
public void When_we_BDDfy_the_class()
12+
{
13+
}
14+
15+
public void Then_the_namespace_is_used_in_the_report()
16+
{
17+
}
18+
19+
[Test]
20+
public void Execute()
21+
{
22+
this.BDDfy();
23+
}
24+
}
25+
}

Samples/TestStack.BDDfy.Samples/TestStack.BDDfy.Samples.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<Compile Include="Atm\HtmlReportConfig.cs" />
5252
<Compile Include="BDDfyConfiguration.cs" />
5353
<Compile Include="BDDfy_Rocks.cs" />
54+
<Compile Include="CanWorkWithoutAStory.cs" />
5455
<Compile Include="TicTacToe\Game.cs" />
5556
<Compile Include="TicTacToe\Helpers.cs" />
5657
<Compile Include="CustomTextReporter.cs" />
@@ -88,4 +89,4 @@
8889
<Target Name="AfterBuild">
8990
</Target>
9091
-->
91-
</Project>
92+
</Project>

TestStack.BDDfy/Processors/Reporters/Html/HtmlReporter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public void Process(IEnumerable<Story> stories)
3333

3434
void WriteOutHtmlReport(IEnumerable<Story> stories)
3535
{
36-
const string error = "There was an error compiling the html report: ";
3736
var viewModel = new HtmlReportViewModel(_configuration, stories);
3837
ShouldTheReportUseCustomization(viewModel);
3938
string report;
@@ -44,7 +43,7 @@ void WriteOutHtmlReport(IEnumerable<Story> stories)
4443
}
4544
catch (Exception ex)
4645
{
47-
report = error + ex.Message;
46+
report = ex.Message + ex.StackTrace;
4847
}
4948

5049
_writer.OutputReport(report, _configuration.OutputFileName, _configuration.OutputPath);

TestStack.BDDfy/Processors/StoryCache.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ public void Process(Story story)
1616
{
1717
foreach (var scenario in story.Scenarios)
1818
{
19-
scenario.TestObject = null;
19+
// ToDo: should uncomment this and find a way to generate file reports with null TestObject.
20+
// Currently it fails when there is no story as the namespace is resolved through TestObject
21+
// scenario.TestObject = null;
22+
2023
foreach (var step in scenario.Steps)
2124
step.StepAction = null;
2225
}

0 commit comments

Comments
 (0)