Exemplo n.º 1
0
        /// <summary>
        /// Runs the async load test info.
        /// </summary>
        /// <returns>The async load test info.</returns>
        /// <param name="cache">Cache.</param>
        /// <remarks>
        /// It loads the test case info from cache if there is something in the cache.
        ///
        /// Otherwise, the test case info is queried from xunit, by executing a separate process of <seealso cref="XUnitTestRunner"/>
        /// with MonoDevelop built-in .NET remoting helper.
        ///
        /// To debug, the .NET remoting part can be commented out, and replaced with direct calls to <seealso cref="XUnitTestRunner"/>.
        /// </remarks>
        void RunAsyncLoadTestInfo(XUnitTestInfoCache cache)
        {
            while (true)
            {
                XUnitAssemblyTestSuite testSuite;
                lock (loadQueue) {
                    if (loadQueue.Count == 0)
                    {
                        if (!Monitor.Wait(loadQueue, 5000, true))
                        {
                            isRunning = false;
                            return;
                        }
                    }
                    testSuite = loadQueue.Dequeue();
                }

                XUnitTestInfo testInfo;

                try {
                    // If the information is cached in a file and it is up to date information,
                    // there is no need to parse again the assembly.

                    if (cache.Exists)
                    {
                        cache.ReadFromDisk();
                        testInfo = cache.GetTestInfo();
                        if (testInfo != null)
                        {
                            testSuite.OnTestSuiteLoaded(testInfo);
                            continue;
                        }
                    }

#if EASY_DEBUGGING
                    var runner = new XUnitRunner.XUnitRunner();
                    testInfo = runner.GetTestInfo(testSuite.AssemblyPath, testSuite.SupportAssemblies.ToArray());
                    testSuite.OnTestSuiteLoaded(testInfo);
#else
                    using (var runner = new ExternalTestRunner()) {
                        runner.Connect(XUnitVersion.XUnit2).Wait();
                        testInfo = runner.GetTestInfo(testSuite.AssemblyPath, testSuite.SupportAssemblies.ToList()).Result;
                        testSuite.OnTestSuiteLoaded(testInfo);
                    }
#endif
                } catch (Exception ex) {
                    LoggingService.LogError(ex.ToString());
                }
            }
        }
Exemplo n.º 2
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);
			}
		}
Exemplo n.º 3
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);
            }
        }
        void RunAsyncLoadTestInfo(XUnitTestInfoCache cache)
        {
            while (true)
            {
                XUnitAssemblyTestSuite testSuite;
                lock (loadQueue) {
                    if (loadQueue.Count == 0)
                    {
                        if (!Monitor.Wait(loadQueue, 5000, true))
                        {
                            isRunning = false;
                            return;
                        }
                    }
                    testSuite = loadQueue.Dequeue();
                }

                XUnitTestInfo testInfo;

                try {
                    // If the information is cached in a file and it is up to date information,
                    // there is no need to parse again the assembly.

                    if (cache.Exists)
                    {
                        cache.ReadFromDisk();
                        testInfo = cache.GetTestInfo();
                        if (testInfo != null)
                        {
                            testSuite.OnTestSuiteLoaded(testInfo);
                            continue;
                        }
                    }
                } catch (Exception ex) {
                    LoggingService.LogError(ex.ToString());
                }

                using (var runner = (XUnitTestRunner)Runtime.ProcessService.CreateExternalProcessObject(typeof(XUnitTestRunner), false)) {
                    testInfo = runner.GetTestInfo(testSuite.AssemblyPath, testSuite.SupportAssemblies.ToArray());
                }

                testSuite.OnTestSuiteLoaded(testInfo);
            }
        }
Exemplo n.º 5
0
		void RunAsyncLoadTestInfo (XUnitTestInfoCache cache)
		{
			while (true) {
				XUnitAssemblyTestSuite testSuite;
				lock (loadQueue) {
					if (loadQueue.Count == 0) {
						if (!Monitor.Wait (loadQueue, 5000, true)) {
							isRunning = false;
							return;
						}
					}
					testSuite = loadQueue.Dequeue ();
				}

				XUnitTestInfo testInfo;

				try {
					// If the information is cached in a file and it is up to date information,
					// there is no need to parse again the assembly.

					if (cache.Exists) {
						cache.ReadFromDisk ();
						testInfo = cache.GetTestInfo ();
						if (testInfo != null) {
							testSuite.OnTestSuiteLoaded (testInfo);
							continue;
						}
					}
				} catch (Exception ex) {
					LoggingService.LogError (ex.ToString ());
				}

				using (var runner = (XUnitTestRunner)Runtime.ProcessService.CreateExternalProcessObject (typeof(XUnitTestRunner), false)) {
					testInfo = runner.GetTestInfo (testSuite.AssemblyPath, testSuite.SupportAssemblies.ToArray());
				}

				testSuite.OnTestSuiteLoaded (testInfo);
			}
		}
 public XUnitAssemblyTestSuite(string name, DotNetProject project) : base(name, project)
 {
     cache = new XUnitTestInfoCache(this);
 }
 public XUnitAssemblyTestSuite(string name) : base(name)
 {
     cache = new XUnitTestInfoCache(this);
 }
		public XUnitAssemblyTestSuite (string name, DotNetProject project): base (name, project)
		{
			cache = new XUnitTestInfoCache (this);
		}
		public XUnitAssemblyTestSuite (string name): base (name)
		{
			cache = new XUnitTestInfoCache (this);
		}