Пример #1
0
        /// <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();
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Unload any loaded TestPackage.
 /// </summary>
 public override void UnloadPackage()
 {
     if (_realRunner != null)
     {
         _realRunner.Unload();
     }
 }
Пример #3
0
 public void Unload()
 {
     if (_runner != null)
     {
         _runner.Unload();
     }
 }
Пример #4
0
 /// <summary>
 /// Unload any loaded TestPackage.
 /// </summary>
 private void UnloadPackage()
 {
     LoadResult = null;
     if (_engineRunner != null)
     {
         _engineRunner.Unload();
     }
 }
Пример #5
0
 /// <summary>
 /// Unload any loaded TestPackage and clear
 /// the reference to the remote runner.
 /// </summary>
 public override void UnloadPackage()
 {
     if (_remoteRunner != null)
     {
         log.Info("Unloading remote runner");
         _remoteRunner.Unload();
         _remoteRunner = null;
     }
 }
Пример #6
0
        private void CommandLoop()
        {
            bool keepRunning  = true;
            var  socketReader = new SocketReader(_clientSocket, new BinarySerializationProtocol());

            while (keepRunning)
            {
                var command = socketReader.GetNextMessage <CommandMessage>();

                switch (command.CommandName)
                {
                case "CreateRunner":
                    var package = (TestPackage)command.Arguments[0];
                    _runner = CreateRunner(package);
                    break;

                case "Load":
                    SendResult(_runner.Load());
                    break;

                case "Reload":
                    SendResult(_runner.Reload());
                    break;

                case "Unload":
                    _runner.Unload();
                    break;

                case "Explore":
                    var filter = (TestFilter)command.Arguments[0];
                    SendResult(_runner.Explore(filter));
                    break;

                case "CountTestCases":
                    filter = (TestFilter)command.Arguments[0];
                    SendResult(_runner.CountTestCases(filter));
                    break;

                case "Run":
                    filter = (TestFilter)command.Arguments[0];
                    SendResult(_runner.Run(this, filter));
                    break;

                case "RunAsync":
                    filter = (TestFilter)command.Arguments[0];
                    _runner.RunAsync(this, filter);
                    break;

                case "Stop":
                    keepRunning = false;
                    break;
                }
            }

            Stop();
        }
Пример #7
0
 /// <summary>
 /// Unload any loaded TestPackage and clear
 /// the reference to the remote runner.
 /// </summary>
 public override void UnloadPackage()
 {
     if (_remoteRunner != null && TestPackage != null)
     {
         try
         {
             log.Info("Unloading " + TestPackage.Name);
             _remoteRunner.Unload();
         }
         catch (Exception e)
         {
             log.Warning("Failed to unload the remote runner. {0}", ExceptionHelper.BuildMessageAndStackTrace(e));
         }
     }
Пример #8
0
 /// <summary>
 /// Unload any loaded TestPackage and clear
 /// the reference to the remote runner.
 /// </summary>
 public override void UnloadPackage()
 {
     try
     {
         if (_remoteRunner != null)
         {
             log.Info("Unloading remote runner");
             _remoteRunner.Unload();
             _remoteRunner = null;
         }
     }
     catch (Exception e)
     {
         log.Warning("Failed to unload the remote runner. {0}", e.Message);
         _remoteRunner = null;
     }
 }