/// <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()); } } }
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); } }
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); } }