@@ -75,51 +75,57 @@ public void Run(IEnumerable<TestMethod> tests)
75
75
&& test . Declaration . QualifiedName . QualifiedModuleName . ComponentName == capturedModule . Key . ComponentName ) ;
76
76
77
77
var fakes = _fakesFactory . GetFakes ( ) ;
78
-
79
- Run ( module . Key . FindModuleInitializeMethods ( _state ) ) ;
80
- foreach ( var test in moduleTestMethods )
78
+ try
81
79
{
82
- // no need to run setup/teardown for ignored tests
83
- if ( test . Declaration . Annotations . Any ( a => a . AnnotationType == AnnotationType . IgnoreTest ) )
80
+ Run ( module . Key . FindModuleInitializeMethods ( _state ) ) ;
81
+ foreach ( var test in moduleTestMethods )
84
82
{
85
- test . UpdateResult ( TestOutcome . Ignored ) ;
86
- OnTestCompleted ( ) ;
87
- continue ;
88
- }
89
-
90
- var stopwatch = new Stopwatch ( ) ;
91
- stopwatch . Start ( ) ;
83
+ // no need to run setup/teardown for ignored tests
84
+ if ( test . Declaration . Annotations . Any ( a => a . AnnotationType == AnnotationType . IgnoreTest ) )
85
+ {
86
+ test . UpdateResult ( TestOutcome . Ignored ) ;
87
+ OnTestCompleted ( ) ;
88
+ continue ;
89
+ }
90
+
91
+ var stopwatch = new Stopwatch ( ) ;
92
+ stopwatch . Start ( ) ;
93
+
94
+ try
95
+ {
96
+ fakes . StartTest ( ) ;
97
+ Run ( testInitialize ) ;
98
+ test . Run ( ) ;
99
+ Run ( testCleanup ) ;
100
+ }
101
+ catch ( COMException ex )
102
+ {
103
+ Logger . Error ( ex , "Unexpected COM exception while running tests." , test . Declaration ? . QualifiedName ) ;
104
+ test . UpdateResult ( TestOutcome . Inconclusive , RubberduckUI . Assert_ComException ) ;
105
+ }
106
+ finally
107
+ {
108
+ fakes . StopTest ( ) ;
109
+ }
110
+
111
+ stopwatch . Stop ( ) ;
112
+ test . Result . SetDuration ( stopwatch . ElapsedMilliseconds ) ;
92
113
93
- try
94
- {
95
- fakes . StartTest ( ) ;
96
- Run ( testInitialize ) ;
97
- test . Run ( ) ;
98
- Run ( testCleanup ) ;
99
- }
100
- catch ( COMException ex )
101
- {
102
- Logger . Error ( ex , "Unexpected COM exception while running tests." , test . Declaration ? . QualifiedName ) ;
103
- test . UpdateResult ( TestOutcome . Inconclusive , RubberduckUI . Assert_ComException ) ;
104
- }
105
- finally
106
- {
107
- fakes . StopTest ( ) ;
114
+ OnTestCompleted ( ) ;
115
+ Model . AddExecutedTest ( test ) ;
108
116
}
109
-
110
- stopwatch . Stop ( ) ;
111
- test . Result . SetDuration ( stopwatch . ElapsedMilliseconds ) ;
112
-
113
- OnTestCompleted ( ) ;
114
- Model . AddExecutedTest ( test ) ;
117
+ Run ( module . Key . FindModuleCleanupMethods ( _state ) ) ;
118
+ }
119
+ finally
120
+ {
121
+ _fakesFactory . Release ( fakes ) ;
115
122
}
116
- Run ( module . Key . FindModuleCleanupMethods ( _state ) ) ;
117
123
}
118
124
}
119
125
120
126
private void Run ( IEnumerable < Declaration > members )
121
127
{
122
- var groupedMembers = members . GroupBy ( m=> m . ProjectName ) ;
128
+ var groupedMembers = members . GroupBy ( m => m . ProjectName ) ;
123
129
foreach ( var group in groupedMembers )
124
130
{
125
131
using ( var project = _vbe . VBProjects [ group . Key ] )
0 commit comments