示例#1
0
        protected override TestExecutionResults ExecuteImpl(string testModule, IEnumerable <IMemberDefinition> testsToRun, string[] args)
        {
            if (!testsToRun.Any())
            {
                // discovery cannot be done
                // When running with empty list of tests XUnit hangs
                return(new TestExecutionResults());
            }

            executedTests.Clear();

            this.testsToRun   = testsToRun;
            executionCanceled = false;
            result            = new TestExecutionResults();

            runner = AssemblyRunner.WithAppDomain(testModule);
            logger.Debug($"Running XUnit executor in App domain: {AppDomain.CurrentDomain.FriendlyName}");

            runner.TestCaseFilter       = TestCaseFilterHandler;
            runner.OnExecutionComplete  = ExecutionCompleteHandler;
            runner.OnTestFailed         = TestFailedHandler;
            runner.OnTestFinished      += TestFinishedHandler;
            runner.OnDiscoveryComplete += DiscoveryCompleteHandler;
            runner.OnErrorMessage      += ErrorMessageHandler;

            logger.Debug("Starting tests");
            runner.Start(maxParallelThreads: 1);

            finished.WaitOne();
            finished.Dispose();

            while (runner.Status != AssemblyRunnerStatus.Idle && !executionCanceled)
            {
                // spin until runner finishes
            }

            if (executionCanceled)
            {
                try
                {
                    runner.Dispose();
                }
                catch (InvalidOperationException e)
                {
                    // for now ignore this exception
                    // due to XUnit bug of not resetting Status to Idle when cancelling run
                }
            }
            else
            {
                runner.Dispose();
            }

            var temp = result;

            // reset result variable
            result = null;
            return(temp);
        }
示例#2
0
        public void TestDisposal()
        {
            AssemblyRunner runner = new AssemblyRunner(Exe);

            runner.Dispose();
            Assert.IsTrue(runner.IsDisposed);
        }
示例#3
0
 public void Dispose()
 {
     impl.Dispose();
 }