/// <summary> /// Cancel the ongoing test run. If no test is running, the call is ignored. /// </summary> /// <param name="force">If true, cancel any ongoing test threads, otherwise wait for them to complete.</param> public void StopRun(bool force) { if (_runner != null) { _runner.StopRun(force); } }
/// <summary> /// Cancel the ongoing test run. If no test is running, the call is ignored. /// </summary> /// <param name="force">If true, cancel any ongoing test threads, otherwise wait for them to complete.</param> public void StopRun(bool force) { _engineRunner.StopRun(force); // Frameworks should handle StopRun(true) by cancelling all tests and notifying // us of the completion of any tests that were running. However, this feature // may be absent in some frameworks or may be broken and we may not pass on the // notifications needed by some runners. In fact, such a bug is present in the // NUnit framework through release 3.12 and motivated the following code. // // We try to make up for the potential problem here by notifying the listeners // of the completion of every pending WorkItem, one that started but never // sent a completion event. Since we have so far only noted this failure wrt // test suites and fixtures, those are the only ones we currently track. // // Note that this code only deals with notifications. If the framework did not // actually stop the run, that's a different problem, which has to be handled // at a lower level within the engine. if (force && !_workItemTracker.WaitForCompletion(WAIT_FOR_CANCEL_TO_COMPLETE)) { _workItemTracker.IssuePendingNotifications(_eventDispatcher); // Indicate we are no longer running IsTestRunning = false; // Signal completion of the run _eventDispatcher.OnTestEvent($"<test-run id='{TestPackage.ID}' result='Failed' label='Cancelled' />"); } }
/// <summary> /// Cancel the ongoing test run. If no test is running, the call is ignored. /// </summary> /// <param name="force">If true, cancel any ongoing test threads, otherwise wait for them to complete.</param> public void StopRun(bool force) { _engineRunner.StopRun(force); if (force) { // Frameworks should handle StopRun(true) by cancelling all tests and notifying // us of the completion of any tests that were running. However, this feature // may be absent in some frameworks or may be broken and we may not pass on the // notifications needed by some runners. In fact, such a bug is present in the // NUnit framework through release 3.12 and motivated the following code. // // We try to make up for the potential problem here by notifying the listeners // of the completion of every pending WorkItem, that is, one that started but // never sent a completion event. if (!_eventDispatcher.WaitForCompletion(WAIT_FOR_CANCEL_TO_COMPLETE)) { _eventDispatcher.IssuePendingNotifications(); // Signal completion of the run _eventDispatcher.OnTestEvent($"<test-run id='{TestPackage.ID}' result='Failed' label='Cancelled' />"); // Since we were not notified of the completion of some items, we can't trust // that they were actually stopped by the framework. To make sure nothing is // left running, we unload the tests. By unloading only the lower-level engine // runner and not the MasterTestRunner itself, we allow the tests to be loaded // for subsequent runs using the same package. _engineRunner.Unload(); } } }
/// <summary> /// Cancel the ongoing test run. If no test is running, the call is ignored. /// </summary> /// <param name="force">If true, cancel any ongoing test threads, otherwise wait for them to complete.</param> public override void StopRun(bool force) { try { _remoteRunner.StopRun(force); } catch (Exception e) { log.Error("Failed to stop the remote run. {0}", e.Message); } }
/// <summary> /// Cancel the ongoing test run. If no test is running, the call is ignored. /// </summary> /// <param name="force">If true, cancel any ongoing test threads, otherwise wait for them to complete.</param> public override void StopRun(bool force) { if (_remoteRunner != null) { try { _remoteRunner.StopRun(force); } catch (Exception e) { log.Error("Failed to stop the remote run. {0}", ExceptionHelper.BuildMessageAndStackTrace(e)); } } }
/// <summary> /// Cancel the ongoing test run. If no test is running, the call is ignored. /// </summary> /// <param name="force">If true, cancel any ongoing test threads, otherwise wait for them to complete.</param> public override void StopRun(bool force) { _remoteRunner.StopRun(force); }
/// <summary> /// Cancel the ongoing test run. If no test is running, the call is ignored. /// </summary> /// <param name="force">If true, cancel any ongoing test threads, otherwise wait for them to complete.</param> public void StopRun(bool force) { _engineRunner.StopRun(force); }
/// <summary> /// Stop the current test run, specifying whether to force cancellation. /// If no test is running, the method returns without error. /// </summary> /// <param name="force">If true, force the stop by cancelling all threads.</param> /// <remarks> /// Note that cancelling the threads is intrinsically unsafe and is only /// provided on the assumption that tests do not impact production data. /// </remarks> public void Stop(bool force) { _runner.StopRun(force); }