Ejemplo n.º 1
0
		public UnitTestResult RunTestSuite (XUnitAssemblyTestSuite rootSuite, XUnitTestSuite testSuite, TestContext context)
		{
			var testCases = new List<XUnitTestCase> ();
			CollectTestCases (testCases, testSuite);

			return Run (testCases, rootSuite, testSuite, context);
		}
        public UnitTestResult RunTestSuite(XUnitAssemblyTestSuite rootSuite, XUnitTestSuite testSuite, TestContext context)
        {
            var testCases = new List <XUnitTestCase> ();

            CollectTestCases(testCases, testSuite);

            return(Run(testCases, rootSuite, testSuite, context));
        }
Ejemplo n.º 3
0
		public UnitTestResult RunAssemblyTestSuite (XUnitAssemblyTestSuite assemblyTestSuite, TestContext context)
		{
			var testCases = new List<XUnitTestCase> ();

			foreach (var test in assemblyTestSuite.Tests) {
				var testSuite = test as XUnitTestSuite;
				if (testSuite != null)
					CollectTestCases (testCases, testSuite);
			}

			return Run (testCases, assemblyTestSuite, assemblyTestSuite, context);
		}
        public UnitTestResult RunAssemblyTestSuite(XUnitAssemblyTestSuite assemblyTestSuite, TestContext context)
        {
            var testCases = new List <XUnitTestCase> ();

            foreach (var test in assemblyTestSuite.Tests)
            {
                var testSuite = test as XUnitTestSuite;
                if (testSuite != null)
                {
                    CollectTestCases(testCases, testSuite);
                }
            }

            return(Run(testCases, assemblyTestSuite, assemblyTestSuite, context));
        }
Ejemplo n.º 5
0
		public void AsyncLoadTestInfo (XUnitAssemblyTestSuite testSuite, XUnitTestInfoCache cache)
		{
			lock (loadQueue) {
				if (!isRunning) {
					var thread = new Thread (new ThreadStart (() => RunAsyncLoadTestInfo (cache))) {
						Name = "xUnit.NET test loader",
						IsBackground = true
					};

					thread.Start ();
					isRunning = true;
				}
				loadQueue.Enqueue (testSuite);
				Monitor.Pulse (loadQueue);
			}
		}
        UnitTestResult Run(List <XUnitTestCase> testCases, XUnitAssemblyTestSuite rootSuite, IExecutableTest test, TestContext context, bool reportToMonitor = true)
        {
            using (var session = test.CreateExecutionSession(reportToMonitor)) {
                var executionListener = new RemoteExecutionListener(new LocalExecutionListener(context, testCases));
                RemotingServices.Marshal(executionListener, null, typeof(IXUnitExecutionListener));

                XUnitTestRunner runner = (XUnitTestRunner)Runtime.ProcessService.CreateExternalProcessObject(typeof(XUnitTestRunner),
                                                                                                             context.ExecutionContext, rootSuite.SupportAssemblies);

                try {
                    runner.Execute(rootSuite.AssemblyPath, testCases.Select(tc => tc.TestInfo).ToArray(), executionListener);
                } finally {
                    runner.Dispose();
                }

                return(session.Result);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Asyncs the load test case info.
        /// </summary>
        /// <returns>The load test info.</returns>
        /// <param name="testSuite">Test suite.</param>
        /// <param name="cache">Cache.</param>
        /// <remarks>
        /// It loads test case info asynchronously.
        /// </remarks>
        public void AsyncLoadTestInfo(XUnitAssemblyTestSuite testSuite, XUnitTestInfoCache cache)
        {
            lock (loadQueue) {
                if (!isRunning)
                {
                    var thread = new Thread(new ThreadStart(() => RunAsyncLoadTestInfo(cache)))
                    {
                        Name         = "xUnit.NET test loader",
                        IsBackground = true
                    };

                    thread.Start();
                    isRunning = true;
                }
                loadQueue.Enqueue(testSuite);
                Monitor.Pulse(loadQueue);
            }
        }
Ejemplo n.º 8
0
		UnitTestResult Run (List<XUnitTestCase> testCases, XUnitAssemblyTestSuite rootSuite, IExecutableTest test, TestContext context, bool reportToMonitor = true)
		{
			using (var session = test.CreateExecutionSession (reportToMonitor)) {
				var executionListener = new RemoteExecutionListener (new LocalExecutionListener (context, testCases));
				RemotingServices.Marshal (executionListener, null, typeof (IXUnitExecutionListener));

				XUnitTestRunner runner = (XUnitTestRunner)Runtime.ProcessService.CreateExternalProcessObject (typeof(XUnitTestRunner),
					context.ExecutionContext, rootSuite.SupportAssemblies);

				try {
					runner.Execute (rootSuite.AssemblyPath, testCases.Select (tc => tc.TestInfo).ToArray (), executionListener);
				} finally {
					runner.Dispose ();
				}

				return session.Result;
			}
		}
        /// <summary>
        /// Run the specified testCases, rootSuite, test, context and reportToMonitor.
        /// </summary>
        /// <param name="testCases">Test cases.</param>
        /// <param name="rootSuite">Root suite.</param>
        /// <param name="test">Test.</param>
        /// <param name="context">Context.</param>
        /// <param name="reportToMonitor">Report to monitor.</param>
        /// <remarks>
        /// This is actual the code that executes the test cases.
        ///
        /// It uses the MonoDevelop built-in .NET remoting helper to execute the code of <seealso cref="XUnitTestRunner"/> in a separate process.
        ///
        /// If any debugging is required, simply comment out the remoting part, and call <seealso cref="XUnitTestRunner"/> directly,
        /// so that the code executes inside MonoDevelop.
        /// </remarks>
        UnitTestResult Run(List <XUnitTestCase> testCases, XUnitAssemblyTestSuite rootSuite, IExecutableTest test, TestContext context, bool reportToMonitor = true)
        {
#if EASY_DEBUGGING
            using (var session = test.CreateExecutionSession(reportToMonitor)) {
                var runner           = new XUnitRunner.XUnitRunner();
                var localTestMonitor = new LocalTestMonitor(context, rootSuite, rootSuite.Name, false);

                string[] nameFilter = new string[testCases.Count];
                for (var i = 0; i < testCases.Count; ++i)
                {
                    nameFilter[i] = testCases[i].TestInfo.Id;
                }

                var path = rootSuite.AssemblyPath;
                runner.Execute(path, nameFilter, localTestMonitor);
                return(session.Result);
            }
#else
            using (var session = test.CreateExecutionSession(reportToMonitor)) {
                using (var runner = new ExternalTestRunner()) {
                    runner.Connect(XUnitVersion.XUnit2, context.ExecutionContext.ExecutionHandler).Wait();
                    var localTestMonitor = new LocalTestMonitor(context, rootSuite, rootSuite.Name, false);

                    string[] nameFilter = new string[testCases.Count];
                    for (var i = 0; i < testCases.Count; ++i)
                    {
                        nameFilter[i] = testCases[i].TestInfo.Id;
                    }

                    var path = rootSuite.AssemblyPath;
                    var supportAssemblies = new List <string>();
                    var crashLogFile      = Path.GetTempFileName();
                    runner.Run(localTestMonitor, nameFilter, path, "", supportAssemblies, null, null, crashLogFile).Wait();
                }
                return(session.Result);
            }
#endif
        }
 public UnitTestResult RunTestCase(XUnitAssemblyTestSuite rootSuite, XUnitTestCase testCase, TestContext context)
 {
     return(Run(new List <XUnitTestCase> {
         testCase
     }, rootSuite, testCase, context, false));
 }
Ejemplo n.º 11
0
 public XUnitTestCase(XUnitAssemblyTestSuite rootSuite, XUnitTestExecutor executor, XUnitTestInfo testInfo) : base(testInfo.Name)
 {
     this.rootSuite = rootSuite;
     TestInfo       = testInfo;
     this.executor  = executor;
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Run the specified testCases, rootSuite, test, context and reportToMonitor.
        /// </summary>
        /// <param name="testCases">Test cases.</param>
        /// <param name="rootSuite">Root suite.</param>
        /// <param name="test">Test.</param>
        /// <param name="context">Context.</param>
        /// <param name="reportToMonitor">Report to monitor.</param>
        /// <remarks>
        /// This is actual the code that executes the test cases.
        ///
        /// It uses the MonoDevelop built-in .NET remoting helper to execute the code of <seealso cref="XUnitTestRunner"/> in a separate process.
        ///
        /// If any debugging is required, simply comment out the remoting part, and call <seealso cref="XUnitTestRunner"/> directly,
        /// so that the code executes inside MonoDevelop.
        /// </remarks>
        UnitTestResult Run(List <XUnitTestCase> testCases, XUnitAssemblyTestSuite rootSuite, IExecutableTest test, TestContext context, bool reportToMonitor = true)
        {
#if EASY_DEBUGGING
            using (var session = test.CreateExecutionSession(reportToMonitor)) {
                var runner           = new XUnitRunner.XUnitRunner();
                var localTestMonitor = new LocalTestMonitor(context, rootSuite, rootSuite.Name, false);

                string[] nameFilter = new string[testCases.Count];
                for (var i = 0; i < testCases.Count; ++i)
                {
                    nameFilter[i] = testCases[i].TestInfo.Id;
                }

                var path = rootSuite.AssemblyPath;
                runner.Execute(path, nameFilter, localTestMonitor);
                return(session.Result);
            }
#else
            using (var session = test.CreateExecutionSession(reportToMonitor)) {
                using (var runner = new ExternalTestRunner()) {
                    runner.Connect(XUnitVersion.XUnit2, context.ExecutionContext.ExecutionHandler).Wait();
                    var localTestMonitor = new LocalTestMonitor(context, rootSuite, rootSuite.Name, false);

                    string[] nameFilter = new string[testCases.Count];
                    for (var i = 0; i < testCases.Count; ++i)
                    {
                        nameFilter[i] = testCases[i].TestInfo.Id;
                    }

                    var path = rootSuite.AssemblyPath;
                    var supportAssemblies = new List <string>();

                    RunData rd = new RunData();
                    rd.Runner       = runner;
                    rd.LocalMonitor = localTestMonitor;

                    var cancelReg = context.Monitor.CancellationToken.Register(rd.Cancel);

                    UnitTestResult result;
                    var            crashLogFile = Path.GetTempFileName();

                    try {
                        context.Monitor.CancellationToken.ThrowIfCancellationRequested();

                        runner.Run(localTestMonitor, nameFilter, path, "", supportAssemblies, null, null, crashLogFile).Wait();
                    } catch (Exception ex) {
                        if (!localTestMonitor.Canceled)
                        {
                            LoggingService.LogError(ex.ToString());
                            result = UnitTestResult.CreateFailure(ex);
                        }
                        else
                        {
                            result = UnitTestResult.CreateFailure(GettextCatalog.GetString("Canceled"), null);
                        }
                    } finally {
                        // Dispose the runner before the console, to make sure the console is available until the runner is disposed.
                        runner.Dispose();
                        cancelReg.Dispose();
                        File.Delete(crashLogFile);
                    }
                }
                return(session.Result);
            }
#endif
        }
 public XUnitTestInfoCache(XUnitAssemblyTestSuite testSuite)
 {
     this.testSuite = testSuite;
 }
Ejemplo n.º 14
0
		public XUnitTestInfoCache (XUnitAssemblyTestSuite testSuite)
		{
			this.testSuite = testSuite;
		}
Ejemplo n.º 15
0
		public XUnitTestCase (XUnitAssemblyTestSuite rootSuite, XUnitTestExecutor executor, XUnitTestInfo testInfo): base (testInfo.Name)
		{
			this.rootSuite = rootSuite;
			TestInfo = testInfo;
			this.executor = executor;
		}
Ejemplo n.º 16
0
		public UnitTestResult RunTestCase (XUnitAssemblyTestSuite rootSuite, XUnitTestCase testCase, TestContext context)
		{
			return Run (new List<XUnitTestCase> { testCase }, rootSuite, testCase, context, false);
		}