Esempio n. 1
0
        public void ExternalBoostTestRunnerProvisioning(string source, string externalExtension, Type type)
        {
            BoostTestRunnerFactoryOptions options = new BoostTestRunnerFactoryOptions();

            if (externalExtension != null)
            {
                options.ExternalTestRunnerSettings = new ExternalBoostTestRunnerSettings
                {
                    ExtensionType        = new Regex(externalExtension),
                    DiscoveryCommandLine = new CommandLine(),
                    ExecutionCommandLine = new CommandLine()
                };
            }

            IBoostTestRunner runner = this.Factory.GetRunner(source, options);

            if (runner == null)
            {
                Assert.That(type, Is.Null);
            }
            else
            {
                Assert.That(runner, Is.AssignableTo(type));
            }
        }
        public void CacheRunnersBasedOnBoostVersion()
        {
            BoostTestRunnerFactoryOptions options = new BoostTestRunnerFactoryOptions
            {
                ForcedBoostTestVersion = DefaultBoostTestRunnerFactory.Boost159
            };

            var runner = Factory.GetRunner("hello", options);

            Assert.That(runner, Is.Not.Null);

            var runner2 = Factory.GetRunner("hello", options);

            Assert.That(runner2, Is.EqualTo(runner));

            var runner3 = Factory.GetRunner("not-hello", options);

            Assert.That(runner3, Is.Not.Null);
            Assert.That(runner3, Is.Not.EqualTo(runner2));

            var runner4 = Factory.GetRunner("hello", new BoostTestRunnerFactoryOptions());

            Assert.That(runner4, Is.Not.Null);
            Assert.That(runner4, Is.Not.EqualTo(runner2));
            Assert.That(runner4, Is.Not.EqualTo(runner3));
        }
            public IBoostTestRunner GetRunner(string source, BoostTestRunnerFactoryOptions options)
            {
                Code.Require(source, "source");
                Code.Require(options, "options");
                Code.Require(options.ExternalTestRunnerSettings, "options.ExternalTestRunnerSettings");

                return(new ExternalBoostTestRunner(source, options.ExternalTestRunnerSettings));
            }
        /// <summary>
        /// Factory function which returns an appropriate IBoostTestRunner
        /// for the provided source or null if not applicable.
        /// </summary>
        /// <param name="source">The test source for which to retrieve the IBoostTestRunner</param>
        /// <returns>An IBoostTestRunner valid for the provided source or null if none are available</returns>
        protected IBoostTestRunner GetTestRunner(string source)
        {
            BoostTestRunnerFactoryOptions options = new BoostTestRunnerFactoryOptions();

            options.ExternalTestRunnerSettings = (this.Settings == null) ? null : this.Settings.ExternalTestRunner;

            return(this.TestRunnerFactory.GetRunner(source, options));
        }
        public IBoostTestRunner GetRunner(string identifier, BoostTestRunnerFactoryOptions options)
        {
            IBoostTestRunner runner = A.Fake <IBoostTestRunner>();

            A.CallTo(() => runner.Source).Returns(identifier);
            A.CallTo(() => runner.ListContentSupported).Returns(ListContentSupport.Contains(identifier));

            return(runner);
        }
Esempio n. 6
0
        /// <summary>
        /// Determines whether the provided source has --list_content capabilities
        /// </summary>
        /// <param name="source">The source to test</param>
        /// <param name="settings">Test adapter settings</param>
        /// <returns>true if the source has list content capabilities; false otherwise</returns>
        private bool IsListContentSupported(string source, BoostTestAdapterSettings settings)
        {
            BoostTestRunnerFactoryOptions options = new BoostTestRunnerFactoryOptions()
            {
                ExternalTestRunnerSettings = settings.ExternalTestRunner
            };

            IBoostTestRunner runner = _factory.GetRunner(source, options);

            return((runner != null) && runner.ListContentSupported);
        }
Esempio n. 7
0
        /// <summary>
        /// Determines whether the provided source has --list_content capabilities
        /// </summary>
        /// <param name="source">The source to test</param>
        /// <param name="settings">Test adapter settings</param>
        /// <returns>true if the source has list content capabilities; false otherwise</returns>
        private bool IsListContentSupported(string source, BoostTestAdapterSettings settings)
        {
            BoostTestRunnerFactoryOptions options = new BoostTestRunnerFactoryOptions()
            {
                ExternalTestRunnerSettings = settings.ExternalTestRunner
            };

            IBoostTestRunner runner = _factory.GetRunner(source, options);

            // Convention over configuration. Assume test runners utilising such an extension
            return((runner != null) && (runner.Source.EndsWith(ForceListContentExtension, StringComparison.OrdinalIgnoreCase) || runner.ListContentSupported));
        }
            public IBoostTestRunner GetRunner(string identifier, BoostTestRunnerFactoryOptions options)
            {
                switch (identifier)
                {
                case TimeoutTestCase:
                {
                    IBoostTestRunner timeoutRunner = A.Fake <IBoostTestRunner>();
                    A.CallTo(() => timeoutRunner.Source).Returns(identifier);
                    A.CallTo(() => timeoutRunner.Run(A <BoostTestRunnerCommandLineArgs> ._, A <BoostTestRunnerSettings> ._)).Throws(new TimeoutException(Timeout));
                    A.CallTo(() => timeoutRunner.Debug(A <BoostTestRunnerCommandLineArgs> ._, A <BoostTestRunnerSettings> ._, A <IFrameworkHandle> ._)).Throws(new TimeoutException(Timeout));

                    return(Provision(timeoutRunner));
                }
                }

                return(Provision(new MockBoostTestRunner(this.Parent, identifier)));
            }
        public Type ExternalBoostTestRunnerProvisioning(string source, string boostTestVersion, string externalExtension)
        {
            var options = new BoostTestRunnerFactoryOptions()
            {
                ForcedBoostTestVersion = (string.IsNullOrEmpty(boostTestVersion)) ? null : Version.Parse(boostTestVersion)
            };

            if (externalExtension != null)
            {
                options.ExternalTestRunnerSettings = new ExternalBoostTestRunnerSettings
                {
                    ExtensionType        = new Regex(externalExtension),
                    ExecutionCommandLine = new CommandLine()
                };
            }

            var runner = Factory.GetRunner(source, options);

            return(runner?.GetType());
        }
Esempio n. 10
0
        public IBoostTestRunner GetRunner(string identifier, BoostTestRunnerFactoryOptions options)
        {
            IBoostTestRunner runner = A.Fake <IBoostTestRunner>();

            var capabilties = new BoostTestRunnerCapabilities
            {
                ListContent = ListContentSupport.Contains(identifier)
            };

            if (options.ForcedBoostTestVersion != null)
            {
                capabilties.ListContent = (options.ForcedBoostTestVersion >= DefaultBoostTestRunnerFactory.Boost159);
                capabilties.Version     = (options.ForcedBoostTestVersion >= DefaultBoostTestRunnerFactory.Boost163);
            }

            A.CallTo(() => runner.Source).Returns(identifier);
            A.CallTo(() => runner.Capabilities).Returns(capabilties);

            return(runner);
        }
Esempio n. 11
0
 public IBoostTestRunner GetRunner(string identifier, BoostTestRunnerFactoryOptions options)
 {
     this.ProvisionedRunners.Add(Tuple.Create(identifier, options, this.TemplateRunner));
     return(this.TemplateRunner);
 }
        public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, ITestCaseDiscoverySink discoverySink)
        {
            Code.Require(sources, "sources");
            Code.Require(discoverySink, "discoverySink");

            // Populate loop-invariant attributes and settings

            BoostTestAdapterSettings settings = BoostTestAdapterSettingsProvider.GetSettings(discoveryContext);

            BoostTestRunnerFactoryOptions options = new BoostTestRunnerFactoryOptions()
            {
                ExternalTestRunnerSettings = settings.ExternalTestRunner
            };

            BoostTestRunnerSettings runnerSettings = new BoostTestRunnerSettings()
            {
                Timeout = settings.DiscoveryTimeoutMilliseconds
            };

            BoostTestRunnerCommandLineArgs args = new BoostTestRunnerCommandLineArgs()
            {
                ListContent = ListContentFormat.DOT
            };

            foreach (var source in sources)
            {
                try
                {
                    args.SetWorkingEnvironment(source, settings, ((_vsProvider == null) ? null : _vsProvider.Instance));
                }
                catch (COMException ex)
                {
                    Logger.Exception(ex, "Could not retrieve WorkingDirectory from Visual Studio Configuration");
                }

                try
                {
                    IBoostTestRunner runner = _factory.GetRunner(source, options);
                    using (TemporaryFile output = new TemporaryFile(TestPathGenerator.Generate(source, ".list.content.gv")))
                    {
                        // --list_content output is redirected to standard error
                        args.StandardErrorFile = output.Path;
                        Logger.Debug("list_content file: {0}", args.StandardErrorFile);

                        runner.Run(args, runnerSettings);

                        // Parse --list_content=DOT output
                        using (FileStream stream = File.OpenRead(args.StandardErrorFile))
                        {
                            TestFrameworkDOTDeserialiser deserialiser = new TestFrameworkDOTDeserialiser(source);

                            // Pass in a visitor to avoid a 2-pass loop in order to notify test cases to VS
                            //
                            // NOTE Due to deserialisation, make sure that only test cases are visited. Test
                            //      suites may be visited after their child test cases are visited.
                            deserialiser.Deserialise(stream, new VSDiscoveryVisitorTestsOnly(source, discoverySink));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Exception(ex, "Exception caught while discovering tests for {0} ({1} - {2})", source, ex.Message, ex.HResult);
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Factory function which returns an appropriate IBoostTestRunner
        /// for the provided source or null if not applicable.
        /// </summary>
        /// <param name="source">The test source for which to retrieve the IBoostTestRunner</param>
        /// <returns>An IBoostTestRunner valid for the provided source or null if none are available</returns>
        protected IBoostTestRunner GetTestRunner(string source)
        {
            BoostTestRunnerFactoryOptions options = ((this.Settings == null) ? new BoostTestRunnerFactoryOptions() : this.Settings.TestRunnerFactoryOptions);

            return(this.TestRunnerFactory.GetRunner(source, options));
        }