Skip to content

Commit

Permalink
Adding exception to Verbose output of MSpec test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
codereflection committed May 19, 2011
1 parent 122c884 commit 3247517
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/Giles.Core/Runners/GilesTestListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public void DisplayResults()

public void DisplayVerboseResults()
{
Console.WriteLine("Verbose results:");
output.Each(x => Console.WriteLine(x));
Console.WriteLine("\n\nVerbose test results:");
output.Each(x => Console.WriteLine(x.Value));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void OnRunEnd()

public void OnContextStart(ContextInfo context)
{
SessionResults.Messages.Add(context.FullName);
SessionResults.Messages.Add(string.Format("\n{0}", context.FullName));
}

public void OnContextEnd(ContextInfo context)
Expand All @@ -65,7 +65,7 @@ public void OnSpecificationStart(SpecificationInfo specification)
public void OnSpecificationEnd(SpecificationInfo specification, Result result)
{
var formatter = resultFormatterFactory.GetResultFormatterFor(result);
SessionResults.Messages.Add(formatter.FormatResult(specification));
SessionResults.Messages.Add(formatter.FormatResult(specification, result));

var testResult = new TestResult { Name = specification.Name, TestRunner = _testRunnerName };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
using System;
using Machine.Specifications;
using Machine.Specifications.Runner;

namespace Giles.Runner.Machine.Specifications
{
public interface IResultFormatter
{
string FormatResult(SpecificationInfo specification);
string FormatResult(SpecificationInfo specification, Result result);
}

public class PassedResultFormatter : IResultFormatter
{
public string FormatResult(SpecificationInfo specification)
public string FormatResult(SpecificationInfo specification, Result result)
{
return String.Format("» {0}", specification.Name);
return String.Format("\t» {0}", specification.Name);
}
}

public class FailedResultFormatter : IResultFormatter
{
public string FormatResult(SpecificationInfo specification)
public string FormatResult(SpecificationInfo specification, Result result)
{
return String.Format("» {0} (FAIL)", specification.Name);
return String.Format("\t» {0} (FAIL)\n{1}", specification.Name, result.Exception);
}
}

public class NotImplementedResultFormatter : IResultFormatter
{
public string FormatResult(SpecificationInfo specification)
public string FormatResult(SpecificationInfo specification, Result result)
{
return String.Format("» {0} (NOT IMPLEMENTED)", specification.Name);
return String.Format("\t» {0} (NOT IMPLEMENTED)", specification.Name);
}
}

public class IgnoredResultFormatter : IResultFormatter
{
public string FormatResult(SpecificationInfo specification)
public string FormatResult(SpecificationInfo specification, Result result)
{
return String.Format("» {0} (IGNORED)", specification.Name);
return String.Format("\t» {0} (IGNORED)", specification.Name);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Runners/Giles.Runner.NUnit/GilesNUnitEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void TestStarted(TestName testName)

public void TestFinished(TestResult result)
{
sessionResults.Messages.Add(string.Format("{0}: {1}", result.Name, result.ResultState.ToString()));
sessionResults.Messages.Add(string.Format("\n{0}: {1}", result.Name, result.ResultState.ToString()));
var testResult = new Core.Runners.TestResult { Name = result.Name, TestRunner = _testRunnerName };
if (result.IsSuccess)
testResult.State = TestState.Passed;
Expand Down

0 comments on commit 3247517

Please sign in to comment.