Пример #1
0
        public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, ITestCaseDiscoverySink discoverySink)
        {
            Code.Require(sources, "sources");
            Code.Require(discoverySink, "discoverySink");

            if (this.Settings.DiscoveryMethodType == DiscoveryMethodType.DiscoveryListContent)
            {
                // Delegate to ListContentDiscoverer
                ListContentDiscoverer discoverer = new ListContentDiscoverer(new ExternalBoostTestRunnerFactory(), VSProvider);
                discoverer.DiscoverTests(sources, discoveryContext, discoverySink);
            }
            else
            {
                foreach (string source in sources)
                {
                    TestFramework framework = DiscoverTestFramework(source);

                    if ((framework != null) && (framework.MasterTestSuite != null))
                    {
                        VSDiscoveryVisitor visitor = new VSDiscoveryVisitor(source, discoverySink);
                        framework.MasterTestSuite.Apply(visitor);
                    }
                }
            }
        }
        public void ListContentSupport()
        {
            IBoostTestRunner runner = A.Fake<IBoostTestRunner>();

            string output = null;

            A.CallTo(() => runner.ListContentSupported).Returns(true);
            A.CallTo(() => runner.Execute(A<BoostTestRunnerCommandLineArgs>._, A<BoostTestRunnerSettings>._, A<IProcessExecutionContext>._)).Invokes((call) =>
            {
                BoostTestRunnerCommandLineArgs args = (BoostTestRunnerCommandLineArgs) call.Arguments.First();
                if ((args.ListContent.HasValue) && (args.ListContent.Value == ListContentFormat.DOT))
                {
                    output = TestHelper.CopyEmbeddedResourceToDirectory("BoostTestAdapterNunit.Resources.ListContentDOT.sample.8.list.content.gv", args.StandardErrorFile);
                }
            });

            FakeBoostTestRunnerFactory factory = new FakeBoostTestRunnerFactory(runner);
            ListContentDiscoverer discoverer = new ListContentDiscoverer(factory, DummyVSProvider.Default);

            DefaultTestContext context = new DefaultTestContext();
            DefaultTestCaseDiscoverySink sink = new DefaultTestCaseDiscoverySink();

            discoverer.DiscoverTests(new[] { "a.exe", }, context, sink);

            // Ensure proper test runner execution
            Assert.That(factory.ProvisionedRunners.Count, Is.EqualTo(1));
            foreach (IBoostTestRunner provisioned in factory.ProvisionedRunners.Select(provision => provision.Item3))
            {
                A.CallTo(() => provisioned.Execute(A<BoostTestRunnerCommandLineArgs>._, A<BoostTestRunnerSettings>._, A<IProcessExecutionContext>._)).
                    WhenArgumentsMatch((arguments) =>
                    {
                        BoostTestRunnerCommandLineArgs args = (BoostTestRunnerCommandLineArgs) arguments.First();

                        return (args.ListContent.HasValue) &&
                                (args.ListContent.Value == ListContentFormat.DOT) &&
                                (!string.IsNullOrEmpty(args.StandardErrorFile));
                    }).
                    MustHaveHappened();
            }

            // Ensure proper test discovery
            Assert.That(sink.Tests.Count, Is.EqualTo(8));

            AssertLabelTrait(sink.Tests.FirstOrDefault((vstest) => (vstest.FullyQualifiedName == "test_2")), "l1");
            AssertLabelTrait(sink.Tests.FirstOrDefault((vstest) => (vstest.FullyQualifiedName == "test_6")), "l1");
            var test_8 = sink.Tests.FirstOrDefault((vstest) => (vstest.FullyQualifiedName == "test_8"));
            AssertLabelTrait(test_8, "l1");
            AssertLabelTrait(test_8, "l2");
            AssertLabelTrait(test_8, "l3 withaspace");

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

            // Ensure proper environment cleanup
            Assert.That(File.Exists(output), Is.False);
        }
        public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, ITestCaseDiscoverySink discoverySink)
        {
            Code.Require(sources, "sources");
            Code.Require(discoverySink, "discoverySink");

            if (this.Settings.DiscoveryMethodType == DiscoveryMethodType.DiscoveryListContent)
            {
                // Delegate to ListContentDiscoverer
                ListContentDiscoverer discoverer = new ListContentDiscoverer(new ExternalBoostTestRunnerFactory(), VSProvider);
                discoverer.DiscoverTests(sources, discoveryContext, discoverySink);
            }
        }
        public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, ITestCaseDiscoverySink discoverySink)
        {
            Code.Require(sources, "sources");
            Code.Require(discoverySink, "discoverySink");

            if (this.Settings.DiscoveryMethodType == DiscoveryMethodType.DiscoveryListContent)
            {
                // Delegate to ListContentDiscoverer
                ListContentDiscoverer discoverer = new ListContentDiscoverer(new ExternalBoostTestRunnerFactory(), VSProvider);
                discoverer.DiscoverTests(sources, discoveryContext, discoverySink);
            }
        }
        public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, ITestCaseDiscoverySink discoverySink)
        {
            Code.Require(sources, "sources");
            Code.Require(discoverySink, "discoverySink");

            if (this.Settings.DiscoveryMethodType == DiscoveryMethodType.DiscoveryListContent)
            {
                // Delegate to ListContentDiscoverer
                ListContentDiscoverer discoverer = new ListContentDiscoverer(new ExternalBoostTestRunnerFactory(), VSProvider);
                discoverer.DiscoverTests(sources, discoveryContext, discoverySink);
            }
            else
            {
                foreach (string source in sources)
                {
                    TestFramework framework = DiscoverTestFramework(source);

                    if ((framework != null) && (framework.MasterTestSuite != null))
                    {
                        VSDiscoveryVisitor visitor = new VSDiscoveryVisitor(source, discoverySink);
                        framework.MasterTestSuite.Apply(visitor);
                    }
                }
            }
        }