|
22 | 22 | * SOFTWARE. |
23 | 23 | */ |
24 | 24 |
|
| 25 | +using System.Reflection; |
25 | 26 | using NUnit.Framework.Interfaces; |
26 | 27 | using NUnit.Framework.Internal; |
27 | 28 | using NUnit.Framework.Internal.Commands; |
@@ -235,22 +236,22 @@ public override TestResult Execute(TestExecutionContext context) |
235 | 236 | context.CurrentResult.SetResult( |
236 | 237 | ResultState.Failure, |
237 | 238 | $"Test exceeded Timeout value of {_timeout}ms"); |
238 | | - // // When the timeout is reached the TearDown methods are not called. This is a best-effort |
239 | | - // // attempt to call them and close the browser / http server. |
240 | | - // foreach (var method in new string[] { "WorkerTeardown", "BrowserTearDown" }) |
241 | | - // { |
242 | | - // var methodFun = context.CurrentTest.Method.MethodInfo.DeclaringType |
243 | | - // .GetMethod(method, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); |
244 | | - // if (methodFun != null) |
245 | | - // { |
246 | | - // var res = methodFun.Invoke(context.TestObject, null); |
247 | | - // if (res is Task task) |
248 | | - // { |
249 | | - // Console.WriteLine($"Waiting for {method} task to complete"); |
250 | | - // task.GetAwaiter().GetResult(); |
251 | | - // } |
252 | | - // } |
253 | | - // } |
| 239 | + // When the timeout is reached the TearDown methods are not called. This is a best-effort |
| 240 | + // attempt to call them and close the browser / http server. |
| 241 | + foreach (var method in new string[] { "WorkerTeardown", "BrowserTearDown" }) |
| 242 | + { |
| 243 | + var methodFun = context.CurrentTest.Method.MethodInfo.DeclaringType |
| 244 | + .GetMethod(method, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); |
| 245 | + if (methodFun != null) |
| 246 | + { |
| 247 | + var res = methodFun.Invoke(context.TestObject, null); |
| 248 | + if (res is Task task) |
| 249 | + { |
| 250 | + Console.WriteLine($"Waiting for {method} task to complete"); |
| 251 | + task.GetAwaiter().GetResult(); |
| 252 | + } |
| 253 | + } |
| 254 | + } |
254 | 255 | } |
255 | 256 | else |
256 | 257 | { |
|
0 commit comments