@@ -60,8 +60,8 @@ private async Task ExecuteTestInternalAsync(AbstractExecutableTest test, Cancell
6060 {
6161 try
6262 {
63- await _stateManager . MarkRunningAsync ( test ) ;
64- await _messageBus . InProgress ( test . Context ) ;
63+ await _stateManager . MarkRunningAsync ( test ) . ConfigureAwait ( false ) ;
64+ await _messageBus . InProgress ( test . Context ) . ConfigureAwait ( false ) ;
6565
6666 _contextRestorer . RestoreContext ( test ) ;
6767
@@ -90,7 +90,7 @@ private async Task ExecuteTestInternalAsync(AbstractExecutableTest test, Cancell
9090 }
9191
9292 // Ensure TestSession hooks run before creating test instances
93- await _testExecutor . EnsureTestSessionHooksExecutedAsync ( ) ;
93+ await _testExecutor . EnsureTestSessionHooksExecutedAsync ( ) . ConfigureAwait ( false ) ;
9494
9595 // Execute test with retry logic - each retry gets a fresh instance
9696 // Timeout is applied per retry attempt, not across all retries
@@ -106,7 +106,7 @@ await RetryHelper.ExecuteWithRetry(test.Context, async () =>
106106 await TimeoutHelper . ExecuteWithTimeoutAsync (
107107 async ct =>
108108 {
109- test . Context . Metadata . TestDetails . ClassInstance = await test . CreateInstanceAsync ( ) ;
109+ test . Context . Metadata . TestDetails . ClassInstance = await test . CreateInstanceAsync ( ) . ConfigureAwait ( false ) ;
110110
111111 // Invalidate cached eligible event objects since ClassInstance changed
112112 test . Context . CachedEligibleEventObjects = null ;
@@ -115,20 +115,20 @@ await TimeoutHelper.ExecuteWithTimeoutAsync(
115115 if ( test . Context . Metadata . TestDetails . ClassInstance is SkippedTestInstance ||
116116 ! string . IsNullOrEmpty ( test . Context . SkipReason ) )
117117 {
118- await _stateManager . MarkSkippedAsync ( test , test . Context . SkipReason ?? "Test was skipped" ) ;
118+ await _stateManager . MarkSkippedAsync ( test , test . Context . SkipReason ?? "Test was skipped" ) . ConfigureAwait ( false ) ;
119119
120- await _eventReceiverOrchestrator . InvokeTestSkippedEventReceiversAsync ( test . Context , ct ) ;
120+ await _eventReceiverOrchestrator . InvokeTestSkippedEventReceiversAsync ( test . Context , ct ) . ConfigureAwait ( false ) ;
121121
122- await _eventReceiverOrchestrator . InvokeTestEndEventReceiversAsync ( test . Context , ct ) ;
122+ await _eventReceiverOrchestrator . InvokeTestEndEventReceiversAsync ( test . Context , ct ) . ConfigureAwait ( false ) ;
123123
124124 return ;
125125 }
126126
127127 try
128128 {
129- await _testInitializer . InitializeTest ( test , ct ) ;
129+ await _testInitializer . InitializeTest ( test , ct ) . ConfigureAwait ( false ) ;
130130 test . Context . RestoreExecutionContext ( ) ;
131- await _testExecutor . ExecuteAsync ( test , ct ) ;
131+ await _testExecutor . ExecuteAsync ( test , ct ) . ConfigureAwait ( false ) ;
132132 }
133133 finally
134134 {
@@ -140,59 +140,59 @@ await TimeoutHelper.ExecuteWithTimeoutAsync(
140140 {
141141 try
142142 {
143- await invocation . InvokeAsync ( test . Context , test . Context ) ;
143+ await invocation . InvokeAsync ( test . Context , test . Context ) . ConfigureAwait ( false ) ;
144144 }
145145 catch ( Exception disposeEx )
146146 {
147- await _logger . LogErrorAsync ( $ "Error during OnDispose for { test . TestId } : { disposeEx } ") ;
147+ await _logger . LogErrorAsync ( $ "Error during OnDispose for { test . TestId } : { disposeEx } ") . ConfigureAwait ( false ) ;
148148 }
149149 }
150150 }
151151
152152 try
153153 {
154- await TestExecutor . DisposeTestInstance ( test ) ;
154+ await TestExecutor . DisposeTestInstance ( test ) . ConfigureAwait ( false ) ;
155155 }
156156 catch ( Exception disposeEx )
157157 {
158- await _logger . LogErrorAsync ( $ "Error disposing test instance for { test . TestId } : { disposeEx } ") ;
158+ await _logger . LogErrorAsync ( $ "Error disposing test instance for { test . TestId } : { disposeEx } ") . ConfigureAwait ( false ) ;
159159 }
160160 }
161161 } ,
162162 testTimeout ,
163163 cancellationToken ,
164- timeoutMessage ) ;
165- } ) ;
164+ timeoutMessage ) . ConfigureAwait ( false ) ;
165+ } ) . ConfigureAwait ( false ) ;
166166
167- await _stateManager . MarkCompletedAsync ( test ) ;
167+ await _stateManager . MarkCompletedAsync ( test ) . ConfigureAwait ( false ) ;
168168
169169 }
170170 catch ( SkipTestException ex )
171171 {
172172 test . Context . SkipReason = ex . Message ;
173- await _stateManager . MarkSkippedAsync ( test , ex . Message ) ;
173+ await _stateManager . MarkSkippedAsync ( test , ex . Message ) . ConfigureAwait ( false ) ;
174174
175- await _eventReceiverOrchestrator . InvokeTestSkippedEventReceiversAsync ( test . Context , cancellationToken ) ;
175+ await _eventReceiverOrchestrator . InvokeTestSkippedEventReceiversAsync ( test . Context , cancellationToken ) . ConfigureAwait ( false ) ;
176176 }
177177 catch ( Exception ex )
178178 {
179- await _stateManager . MarkFailedAsync ( test , ex ) ;
179+ await _stateManager . MarkFailedAsync ( test , ex ) . ConfigureAwait ( false ) ;
180180 }
181181 finally
182182 {
183183 var cleanupExceptions = new List < Exception > ( ) ;
184184
185- await _objectTracker . UntrackObjects ( test . Context , cleanupExceptions ) ;
185+ await _objectTracker . UntrackObjects ( test . Context , cleanupExceptions ) . ConfigureAwait ( false ) ;
186186
187187 var testClass = test . Metadata . TestClassType ;
188188 var testAssembly = testClass . Assembly ;
189- var hookExceptions = await _testExecutor . ExecuteAfterClassAssemblyHooks ( test , testClass , testAssembly , CancellationToken . None ) ;
189+ var hookExceptions = await _testExecutor . ExecuteAfterClassAssemblyHooks ( test , testClass , testAssembly , CancellationToken . None ) . ConfigureAwait ( false ) ;
190190
191191 if ( hookExceptions . Count > 0 )
192192 {
193193 foreach ( var ex in hookExceptions )
194194 {
195- await _logger . LogErrorAsync ( $ "Error executing After hooks for { test . TestId } : { ex } ") ;
195+ await _logger . LogErrorAsync ( $ "Error executing After hooks for { test . TestId } : { ex } ") . ConfigureAwait ( false ) ;
196196 }
197197 cleanupExceptions . AddRange ( hookExceptions ) ;
198198 }
@@ -203,11 +203,11 @@ await TimeoutHelper.ExecuteWithTimeoutAsync(
203203 await _eventReceiverOrchestrator . InvokeLastTestInClassEventReceiversAsync (
204204 test . Context ,
205205 test . Context . ClassContext ,
206- CancellationToken . None ) ;
206+ CancellationToken . None ) . ConfigureAwait ( false ) ;
207207 }
208208 catch ( Exception ex )
209209 {
210- await _logger . LogErrorAsync ( $ "Error in last test in class event receiver for { test . TestId } : { ex } ") ;
210+ await _logger . LogErrorAsync ( $ "Error in last test in class event receiver for { test . TestId } : { ex } ") . ConfigureAwait ( false ) ;
211211 cleanupExceptions . Add ( ex ) ;
212212 }
213213
@@ -216,11 +216,11 @@ await _eventReceiverOrchestrator.InvokeLastTestInClassEventReceiversAsync(
216216 await _eventReceiverOrchestrator . InvokeLastTestInAssemblyEventReceiversAsync (
217217 test . Context ,
218218 test . Context . ClassContext . AssemblyContext ,
219- CancellationToken . None ) ;
219+ CancellationToken . None ) . ConfigureAwait ( false ) ;
220220 }
221221 catch ( Exception ex )
222222 {
223- await _logger . LogErrorAsync ( $ "Error in last test in assembly event receiver for { test . TestId } : { ex } ") ;
223+ await _logger . LogErrorAsync ( $ "Error in last test in assembly event receiver for { test . TestId } : { ex } ") . ConfigureAwait ( false ) ;
224224 cleanupExceptions . Add ( ex ) ;
225225 }
226226
@@ -229,11 +229,11 @@ await _eventReceiverOrchestrator.InvokeLastTestInAssemblyEventReceiversAsync(
229229 await _eventReceiverOrchestrator . InvokeLastTestInSessionEventReceiversAsync (
230230 test . Context ,
231231 test . Context . ClassContext . AssemblyContext . TestSessionContext ,
232- CancellationToken . None ) ;
232+ CancellationToken . None ) . ConfigureAwait ( false ) ;
233233 }
234234 catch ( Exception ex )
235235 {
236- await _logger . LogErrorAsync ( $ "Error in last test in session event receiver for { test . TestId } : { ex } ") ;
236+ await _logger . LogErrorAsync ( $ "Error in last test in session event receiver for { test . TestId } : { ex } ") . ConfigureAwait ( false ) ;
237237 cleanupExceptions . Add ( ex ) ;
238238 }
239239
@@ -244,7 +244,7 @@ await _eventReceiverOrchestrator.InvokeLastTestInSessionEventReceiversAsync(
244244 ? cleanupExceptions [ 0 ]
245245 : new AggregateException ( "One or more errors occurred during test cleanup" , cleanupExceptions ) ;
246246
247- await _stateManager . MarkFailedAsync ( test , aggregatedException ) ;
247+ await _stateManager . MarkFailedAsync ( test , aggregatedException ) . ConfigureAwait ( false ) ;
248248 }
249249
250250 switch ( test . State )
@@ -254,20 +254,20 @@ await _eventReceiverOrchestrator.InvokeLastTestInSessionEventReceiversAsync(
254254 case TestState . Queued :
255255 case TestState . Running :
256256 // This shouldn't happen
257- await _messageBus . Cancelled ( test . Context , test . StartTime . GetValueOrDefault ( ) ) ;
257+ await _messageBus . Cancelled ( test . Context , test . StartTime . GetValueOrDefault ( ) ) . ConfigureAwait ( false ) ;
258258 break ;
259259 case TestState . Passed :
260- await _messageBus . Passed ( test . Context , test . StartTime . GetValueOrDefault ( ) ) ;
260+ await _messageBus . Passed ( test . Context , test . StartTime . GetValueOrDefault ( ) ) . ConfigureAwait ( false ) ;
261261 break ;
262262 case TestState . Timeout :
263263 case TestState . Failed :
264- await _messageBus . Failed ( test . Context , test . Context . Execution . Result ? . Exception ! , test . StartTime . GetValueOrDefault ( ) ) ;
264+ await _messageBus . Failed ( test . Context , test . Context . Execution . Result ? . Exception ! , test . StartTime . GetValueOrDefault ( ) ) . ConfigureAwait ( false ) ;
265265 break ;
266266 case TestState . Skipped :
267- await _messageBus . Skipped ( test . Context , test . Context . SkipReason ?? "Skipped" ) ;
267+ await _messageBus . Skipped ( test . Context , test . Context . SkipReason ?? "Skipped" ) . ConfigureAwait ( false ) ;
268268 break ;
269269 case TestState . Cancelled :
270- await _messageBus . Cancelled ( test . Context , test . StartTime . GetValueOrDefault ( ) ) ;
270+ await _messageBus . Cancelled ( test . Context , test . StartTime . GetValueOrDefault ( ) ) . ConfigureAwait ( false ) ;
271271 break ;
272272 default :
273273 throw new ArgumentOutOfRangeException ( ) ;
0 commit comments