public MultiplexedTestRunner(IUnityContainer container, IOptions options) : base(container)
        {
            _options = options;
            UpdateImplementation();

            foreach (var implementation in _implementations.Values)
            {
                implementation.DebuggingStarted += (o, e) => DebuggingStarted?.Invoke(this, e);
                implementation.TestStarted      += (o, e) => TestStarted?.Invoke(this, e);
                implementation.TestExecuted     += (o, e) => TestExecuted?.Invoke(this, e);
                implementation.TestLogAdded     += (o, e) => TestLogAdded?.Invoke(this, e);
                implementation.TestsAborted     += (o, e) => TestsAborted?.Invoke(this, e);
                implementation.TestsFailed      += (o, e) => TestsFailed?.Invoke(this, e);
                implementation.TestsFinished    += (o, e) => TestsFinished?.Invoke(this, e);
                implementation.TestsStarted     += (o, e) => TestsStarted?.Invoke(this, e);
            }

            options.PropertyChanged += OnOptionChanged;
        }
Beispiel #2
0
        public Task RunTestsAsync(TestItem testItem, bool isCovering = true, bool isDebugging = false)
        {
            if (IsBusy)
            {
                throw new InvalidOperationException("The test runner is busy. Please wait for tests to complete or abort.");
            }

            _testTask = Task.Run(() =>
            {
                try
                {
                    OnTestLogAdded(Resources.TestExecutionStarted);
                    var result = RunTests(testItem, isCovering, isDebugging);

                    _testTask = null;
                    OnTestsFinished(result);
                    OnTestLogAdded(Resources.TestExecutionFinished);
                }
                catch (Exception e)
                {
                    if (!_isAborting)
                    {
                        OnTestLogAdded(Resources.TestExecutionFailed);
                        OnTestLogAdded(e.GetDescription());
                    }
                    else
                    {
                        OnTestLogAdded(Resources.TestRunAborted);
                    }

                    _testTask = null;
                    OnTestsFinished(null);
                }
                finally
                {
                    _testTask   = null;
                    _isAborting = false;
                }
            });
            TestsStarted?.Invoke(this, new EventArgs <TestItem>(testItem));
            return(_testTask);
        }