Esempio n. 1
0
 public TestableTestPluginCache(List <string> extensionsPath)
 {
     TestDiscoveryExtensionManager.Destroy();
     TestExecutorExtensionManager.Destroy();
     SettingsProviderExtensionManager.Destroy();
     this.UpdateExtensions(extensionsPath, skipExtensionFilters: false);
 }
Esempio n. 2
0
 public TestableTestPluginCache(IFileHelper fileHelper, List <string> extensionsPath) : base(fileHelper)
 {
     TestDiscoveryExtensionManager.Destroy();
     TestExecutorExtensionManager.Destroy();
     SettingsProviderExtensionManager.Destroy();
     this.UpdateExtensions(extensionsPath, true);
 }
Esempio n. 3
0
        private static IEnumerable <LazyExtension <ITestDiscoverer, ITestDiscovererCapabilities> > GetDiscoverers(
            string extensionAssembly,
            bool throwOnError)
        {
            try
            {
                if (string.IsNullOrEmpty(extensionAssembly) || string.Equals(extensionAssembly, Constants.UnspecifiedAdapterPath))
                {
                    // full discovery.
                    return(TestDiscoveryExtensionManager.Create().Discoverers);
                }
                else
                {
                    return(TestDiscoveryExtensionManager.GetDiscoveryExtensionManager(extensionAssembly).Discoverers);
                }
            }
            catch (Exception ex)
            {
                EqtTrace.Error($"TestDiscoveryManager: LoadExtensions: Exception occured while loading extensions {ex}");
                if (throwOnError)
                {
                    throw;
                }

                return(null);
            }
        }
Esempio n. 4
0
        public void InitializeShouldLoadAndInitializeAllExtension()
        {
            var assemblyLocation = typeof(TestDiscoveryExtensionManagerTests).GetTypeInfo().Assembly.Location;
            this.executionManager.Initialize(new List<string> { assemblyLocation });

            Assert.IsNotNull(TestPluginCache.Instance.TestExtensions);

            // Discoverers
            Assert.IsTrue(TestPluginCache.Instance.TestExtensions.TestDiscoverers.Count > 0);
            var allDiscoverers = TestDiscoveryExtensionManager.Create().Discoverers;

            foreach (var discoverer in allDiscoverers)
            {
                Assert.IsTrue(discoverer.IsExtensionCreated);
            }

            // Executors
            Assert.IsTrue(TestPluginCache.Instance.TestExtensions.TestExecutors.Count > 0);
            var allExecutors = TestExecutorExtensionManager.Create().TestExtensions;

            foreach (var executor in allExecutors)
            {
                Assert.IsTrue(executor.IsExtensionCreated);
            }

            // Settings Providers
            Assert.IsTrue(TestPluginCache.Instance.TestExtensions.TestSettingsProviders.Count > 0);
            var settingsProviders = SettingsProviderExtensionManager.Create().SettingsProvidersMap.Values;

            foreach (var provider in settingsProviders)
            {
                Assert.IsTrue(provider.IsExtensionCreated);
            }
        }
Esempio n. 5
0
        private void LoadExtensions()
        {
            try
            {
                // Load the extensions on creation so that we dont have to spend time during first execution.
                EqtTrace.Verbose("TestExecutorService: Loading the extensions");

                TestDiscoveryExtensionManager.LoadAndInitializeAllExtensions(false);

                EqtTrace.Verbose("TestExecutorService: Loaded the discoverers");

                TestExecutorExtensionManager.LoadAndInitializeAllExtensions(false);

                EqtTrace.Verbose("TestExecutorService: Loaded the executors");

                SettingsProviderExtensionManager.LoadAndInitializeAllExtensions(false);

                EqtTrace.Verbose("TestExecutorService: Loaded the settings providers");
                EqtTrace.Info("TestExecutorService: Loaded the extensions");
            }
            catch (Exception ex)
            {
                if (EqtTrace.IsWarningEnabled)
                {
                    EqtTrace.Warning("TestExecutorWebService: Exception occured while calling test connection. {0}", ex);
                }
            }
        }
Esempio n. 6
0
        public void TestInit()
        {
            this.mockTestPlatformEventSource = new Mock <ITestPlatformEventSource>();
            this.discoveryResultCache        = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { });
            this.discovererEnumerator        = new DiscovererEnumerator(this.discoveryResultCache, this.mockTestPlatformEventSource.Object);

            TestDiscoveryExtensionManager.Destroy();
        }
Esempio n. 7
0
        public void GetDiscoveryExtensionManagerShouldReturnADiscoveryManagerWithExtensions()
        {
            var extensionManager =
                TestDiscoveryExtensionManager.GetDiscoveryExtensionManager(
                    typeof(TestDiscoveryExtensionManagerTests).GetTypeInfo().Assembly.Location);

            Assert.IsNotNull(extensionManager.Discoverers);
            Assert.IsTrue(extensionManager.Discoverers.Any());
        }
Esempio n. 8
0
        public void CreateShouldDiscoverDiscovererExtensions()
        {
            TestPluginCacheHelper.SetupMockExtensions(typeof(TestDiscoveryExtensionManagerTests));

            var extensionManager = TestDiscoveryExtensionManager.Create();

            Assert.IsNotNull(extensionManager.Discoverers);
            Assert.IsTrue(extensionManager.Discoverers.Any());
        }
        public void CreateShouldDiscoverDiscovererExtensions()
        {
            TestPluginCacheTests.SetupMockExtensions();

            var extensionManager = TestDiscoveryExtensionManager.Create();

            Assert.IsNotNull(extensionManager.Discoverers);
            Assert.IsTrue(extensionManager.Discoverers.Count() > 0);
        }
Esempio n. 10
0
        public void TestCleanup()
        {
            RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = null;
            RunTestWithSourcesExecutor.RunTestsWithTestsCallback   = null;

            TestDiscoveryExtensionManager.Destroy();
            TestExecutorExtensionManager.Destroy();
            SettingsProviderExtensionManager.Destroy();
        }
        public void TestInit()
        {
            this.mockTestPlatformEventSource = new Mock <ITestPlatformEventSource>();
            this.discoveryResultCache        = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { });
            this.mockRequestData             = new Mock <IRequestData>();
            this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection());
            this.discovererEnumerator = new DiscovererEnumerator(this.mockRequestData.Object, this.discoveryResultCache, this.mockTestPlatformEventSource.Object);

            TestDiscoveryExtensionManager.Destroy();
        }
Esempio n. 12
0
        public void CreateShouldCacheDiscoveredExtensions()
        {
            TestPluginCacheHelper.SetupMockExtensions(typeof(TestDiscoveryExtensionManagerTests), () => { });

            var extensionManager = TestDiscoveryExtensionManager.Create();

            TestDiscoveryExtensionManager.Create();

            Assert.IsNotNull(extensionManager.Discoverers);
            Assert.IsTrue(extensionManager.Discoverers.Count() > 0);
        }
Esempio n. 13
0
        /// <summary>
        /// Initializes the discovery manager.
        /// </summary>
        /// <param name="pathToAdditionalExtensions"> The path to additional extensions. </param>
        public void Initialize(IEnumerable <string> pathToAdditionalExtensions)
        {
            this.testPlatformEventSource.AdapterSearchStart();

            // Start using these additional extensions
            TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions;

            // Load and Initialize extensions.
            TestDiscoveryExtensionManager.LoadAndInitializeAllExtensions(false);
            this.testPlatformEventSource.AdapterSearchStop();
        }
Esempio n. 14
0
        /// <summary>
        /// Initializes the discovery manager.
        /// </summary>
        /// <param name="pathToAdditionalExtensions"> The path to additional extensions. </param>
        public void Initialize(IEnumerable <string> pathToAdditionalExtensions)
        {
            this.testPlatformEventSource.AdapterSearchStart();

            // Start using these additional extensions
            TestPluginCache.Instance.UpdateAdditionalExtensions(pathToAdditionalExtensions, shouldLoadOnlyWellKnownExtensions: false);

            // Load and Initialize extensions.
            TestDiscoveryExtensionManager.LoadAndInitializeAllExtensions(false);
            this.testPlatformEventSource.AdapterSearchStop();
        }
Esempio n. 15
0
        public void LoadAndInitializeShouldInitializeAllExtensions()
        {
            TestPluginCacheHelper.SetupMockExtensions(typeof(TestDiscoveryExtensionManagerTests));

            TestDiscoveryExtensionManager.LoadAndInitializeAllExtensions(false);

            var allDiscoverers = TestDiscoveryExtensionManager.Create().Discoverers;

            foreach (var discoverer in allDiscoverers)
            {
                Assert.IsTrue(discoverer.IsExtensionCreated);
            }
        }
        /// <summary>
        /// Initializes the discovery manager.
        /// </summary>
        /// <param name="pathToAdditionalExtensions"> The path to additional extensions. </param>
        public void Initialize(IEnumerable <string> pathToAdditionalExtensions, ITestDiscoveryEventsHandler2 eventHandler)
        {
            this.testPlatformEventSource.AdapterSearchStart();
            this.testDiscoveryEventsHandler = eventHandler;
            if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Any())
            {
                // Start using these additional extensions
                TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions;
            }

            // Load and Initialize extensions.
            TestDiscoveryExtensionManager.LoadAndInitializeAllExtensions(false);
            this.testPlatformEventSource.AdapterSearchStop();
        }
        public void CreateShouldCacheDiscoveredExtensions()
        {
            var discoveryCount = 0;

            TestPluginCacheTests.SetupMockExtensions(() => { discoveryCount++; });

            var extensionManager = TestDiscoveryExtensionManager.Create();

            TestDiscoveryExtensionManager.Create();

            Assert.IsNotNull(extensionManager.Discoverers);
            Assert.IsTrue(extensionManager.Discoverers.Count() > 0);
            Assert.AreEqual(1, discoveryCount);
        }
Esempio n. 18
0
        public ArgumentProcessorResult Execute()
        {
            ConsoleOutput.Instance.WriteLine(CommandLineResources.AvailableDiscoverersHeaderMessage, OutputLevel.Information);
            var testPlatform     = TestPlatformFactory.GetTestPlatform();
            var extensionManager = TestDiscoveryExtensionManager.Create();

            foreach (var extension in extensionManager.Discoverers)
            {
                ConsoleOutput.Instance.WriteLine(extension.Value.GetType().FullName, OutputLevel.Information);
                ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.UriOfDefaultExecutor, extension.Metadata.DefaultExecutorUri), OutputLevel.Information);
                ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.SupportedFileTypesIndicator + " " + string.Join(", ", extension.Metadata.FileExtension)), OutputLevel.Information);
            }

            return(ArgumentProcessorResult.Success);
        }
Esempio n. 19
0
 public DiscovererEnumeratorTests()
 {
     this.mockTestPlatformEventSource = new Mock <ITestPlatformEventSource>();
     this.discoveryResultCache        = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { });
     this.mockRequestData             = new Mock <IRequestData>();
     this.mockMetricsCollection       = new Mock <IMetricsCollection>();
     this.mockAssemblyProperties      = new Mock <IAssemblyProperties>();
     this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object);
     this.discovererEnumerator = new DiscovererEnumerator(this.mockRequestData.Object, this.discoveryResultCache, this.mockTestPlatformEventSource.Object, this.mockAssemblyProperties.Object, this.cancellationTokenSource.Token);
     this.runSettingsMock      = new Mock <IRunSettings>();
     this.messageLoggerMock    = new Mock <IMessageLogger>();
     TestPluginCacheTests.SetupMockExtensions(new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location },
                                              () => { });
     TestDiscoveryExtensionManager.Destroy();
 }
Esempio n. 20
0
        public void InitializeShouldUpdateAdditionalExtenions()
        {
            var mockFileHelper = new Mock <IFileHelper>();

            mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny <string>())).Returns(false);
            TestPluginCache.Instance = new TestableTestPluginCache(mockFileHelper.Object);

            this.discoveryManager.Initialize(
                new string[] { typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location });

            var allDiscoverers = TestDiscoveryExtensionManager.Create().Discoverers;

            Assert.IsNotNull(allDiscoverers);
            Assert.IsTrue(allDiscoverers.Count() > 0);
        }
Esempio n. 21
0
 public void TestCleanup()
 {
     TestDiscoveryExtensionManager.Destroy();
     TestPluginCache.Instance = null;
 }
Esempio n. 22
0
 public void TestCleanup()
 {
     TestDiscoveryExtensionManager.Destroy();
 }