@@ -10,9 +10,10 @@ class FailedSpecificationsSummary
1010 readonly IConsole _console ;
1111
1212 readonly Dictionary < ContextInfo , IList < FailedSpecification > > _failures =
13- new Dictionary < ContextInfo , IList < FailedSpecification > > ( ) ;
13+ new Dictionary < ContextInfo , IList < FailedSpecification > > ( ) ;
1414
1515 readonly VerboseOutput _verbose ;
16+ readonly IList < ExceptionResult > _fatalErrors = new List < ExceptionResult > ( ) ;
1617
1718 public FailedSpecificationsSummary ( VerboseOutput verbose , IConsole console )
1819 {
@@ -21,6 +22,17 @@ public FailedSpecificationsSummary(VerboseOutput verbose, IConsole console)
2122 }
2223
2324 public void WriteSummary ( )
25+ {
26+ if ( ! _failures . Any ( ) && ! _fatalErrors . Any ( ) )
27+ {
28+ return ;
29+ }
30+
31+ WriteFailures ( ) ;
32+ WriteFatalErrors ( ) ;
33+ }
34+
35+ void WriteFailures ( )
2436 {
2537 if ( ! _failures . Any ( ) )
2638 {
@@ -31,17 +43,33 @@ public void WriteSummary()
3143 _console . WriteLine ( "Failures:" ) ;
3244
3345 _failures
34- . OrderBy ( context => context . Key . FullName )
35- . ToList ( )
36- . ForEach ( context =>
37- {
38- _verbose . ContextStart ( context . Key ) ;
39- context . Value . ToList ( ) . ForEach ( spec =>
40- {
41- _verbose . SpecificationStart ( spec . Specification ) ;
42- _verbose . Failed ( spec . Specification , spec . Result ) ;
43- } ) ;
44- } ) ;
46+ . OrderBy ( context => context . Key . FullName )
47+ . ToList ( )
48+ . ForEach ( context =>
49+ {
50+ _verbose . ContextStart ( context . Key ) ;
51+ context . Value . ToList ( ) . ForEach ( spec =>
52+ {
53+ _verbose . SpecificationStart ( spec . Specification ) ;
54+ _verbose . Failed ( spec . Specification , spec . Result ) ;
55+ } ) ;
56+ } ) ;
57+ }
58+
59+ void WriteFatalErrors ( )
60+ {
61+ if ( ! _fatalErrors . Any ( ) )
62+ {
63+ return ;
64+ }
65+
66+ _console . WriteLine ( "" ) ;
67+ _console . WriteLine ( "Fatal Errors:" ) ;
68+
69+ _fatalErrors
70+ . ToList ( )
71+ . ForEach ( x => _verbose . FatalError ( x ) ) ;
72+
4573 }
4674
4775 public void RecordFailure ( ContextInfo context , SpecificationInfo specification , Result result )
@@ -54,5 +82,10 @@ public void RecordFailure(ContextInfo context, SpecificationInfo specification,
5482 var entry = _failures [ context ] ;
5583 entry . Add ( new FailedSpecification { Specification = specification , Result = result } ) ;
5684 }
85+
86+ public void RecordFatalError ( ExceptionResult exception )
87+ {
88+ _fatalErrors . Add ( exception ) ;
89+ }
5790 }
58- }
91+ }
0 commit comments