当前位置: 首页>>代码示例>>C#>>正文


C# IRunContext类代码示例

本文整理汇总了C#中IRunContext的典型用法代码示例。如果您正苦于以下问题:C# IRunContext类的具体用法?C# IRunContext怎么用?C# IRunContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IRunContext类属于命名空间,在下文中一共展示了IRunContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunTests

        /// <summary>
        /// Runs the tests.
        /// </summary>
        /// <param name="tests">Which tests should be run.</param>
        /// <param name="context">Context in which to run tests.</param>
        /// <param param name="framework">Where results should be stored.</param>
        public void RunTests(IEnumerable<TestCase> tests, IRunContext context, IFrameworkHandle framework)
        {
            _state = ExecutorState.Running;

            foreach (var test in tests)
            {
                if (_state == ExecutorState.Cancelling)
                {
                    _state = ExecutorState.Cancelled;
                    return;
                }

                try
                {
                    var reportDocument = RunOrDebugCatchTest(test.Source, test.FullyQualifiedName, context, framework);
                    var result = GetTestResultFromReport(test, reportDocument, framework);
                    framework.RecordResult(result);
                }
                catch (Exception ex)
                {
                    // Log it and move on. It will show up to the user as a test that hasn't been run.
                    framework.SendMessage(TestMessageLevel.Error, "Exception occured when processing test case: " + test.FullyQualifiedName);
                    framework.SendMessage(TestMessageLevel.Informational, "Message: " + ex.Message + "\nStacktrace:" + ex.StackTrace);
                }
            }
        }
开发者ID:mrpi,项目名称:CatchVsTestAdapter,代码行数:32,代码来源:CatchTestExecutor.cs

示例2: RunTests

        // NOTE: an earlier version of this code had a FilterBuilder
        // property. This seemed to make sense, because we instantiate
        // it in two different places. However, the existence of an
        // NUnitTestFilterBuilder, containing a reference to an engine 
        // service caused our second-level tests of the test executor
        // to throw an exception. So if you consider doing this, beware!

        #endregion

        #region ITestExecutor Implementation

        /// <summary>
        /// Called by the Visual Studio IDE to run all tests. Also called by TFS Build
        /// to run either all or selected tests. In the latter case, a filter is provided
        /// as part of the run context.
        /// </summary>
        /// <param name="sources">Sources to be run.</param>
        /// <param name="runContext">Context to use when executing the tests.</param>
        /// <param name="frameworkHandle">Test log to send results and messages through</param>
        public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
#if LAUNCHDEBUGGER
            if (!Debugger.IsAttached)
                Debugger.Launch();
#endif
            Initialize(runContext, frameworkHandle);

            try
            {
                foreach (var source in sources)
                {
                    var assemblyName = source;
                    if (!Path.IsPathRooted(assemblyName))
                        assemblyName = Path.Combine(Environment.CurrentDirectory, assemblyName);

                    TestLog.Info("Running all tests in " + assemblyName);

                    RunAssembly(assemblyName, TestFilter.Empty);
                }
            }
            catch (Exception ex)
            {
                if (ex is TargetInvocationException)
                    ex = ex.InnerException;
                TestLog.Error("Exception thrown executing tests", ex);
            }
            finally
            {
                TestLog.Info(string.Format("NUnit Adapter {0}: Test execution complete", AdapterVersion));
                Unload();
            }

        }
开发者ID:MSK61,项目名称:nunit3-vs-adapter,代码行数:53,代码来源:NUnit3TestExecutor.cs

示例3: GetTestCaseFilterExpression

        bool GetTestCaseFilterExpression(IRunContext runContext, LoggerHelper logger, string assemblyFileName, out ITestCaseFilterExpression filter)
        {
            filter = null;

            try
            {
                // In Microsoft.VisualStudio.TestPlatform.ObjectModel V11 IRunContext provides a TestCaseFilter property
                // GetTestCaseFilter only exists in V12+
#if PLATFORM_DOTNET
                var getTestCaseFilterMethod = runContext.GetType().GetRuntimeMethod("GetTestCaseFilter", new[] { typeof(IEnumerable<string>), typeof(Func<string, TestProperty>) });
#else
                var getTestCaseFilterMethod = runContext.GetType().GetMethod("GetTestCaseFilter");
#endif
                if (getTestCaseFilterMethod != null)
                    filter = (ITestCaseFilterExpression)getTestCaseFilterMethod.Invoke(runContext, new object[] { supportedPropertyNames, null });

                return true;
            }
            catch (TargetInvocationException e)
            {
                var innerExceptionType = e.InnerException.GetType();
                if (innerExceptionType.FullName.EndsWith("TestPlatformFormatException", StringComparison.OrdinalIgnoreCase))
                {
                    logger.LogError("{0}: Exception discovering tests: {1}", Path.GetFileNameWithoutExtension(assemblyFileName), e.InnerException.Message);
                    return false;
                }

                throw;
            }
        }
开发者ID:tmulkern,项目名称:visualstudio.xunit,代码行数:30,代码来源:TestCaseFilterHelper.cs

示例4: RunTests

        public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            IMessageLogger log = frameworkHandle;

            log.Version();

            HandlePoorVisualStudioImplementationDetails(runContext, frameworkHandle);

            foreach (var assemblyPath in sources)
            {
                try
                {
                    if (AssemblyDirectoryContainsFixie(assemblyPath))
                    {
                        log.Info("Processing " + assemblyPath);

                        var listener = new VisualStudioListener(frameworkHandle, assemblyPath);

                        using (var environment = new ExecutionEnvironment(assemblyPath))
                        {
                            environment.RunAssembly(new Options(), listener);
                        }
                    }
                    else
                    {
                        log.Info("Skipping " + assemblyPath + " because it is not a test assembly.");
                    }
                }
                catch (Exception exception)
                {
                    log.Error(exception);
                }
            }
        }
开发者ID:scichelli,项目名称:fixie,代码行数:34,代码来源:VsTestExecutor.cs

示例5: RunTests

 public void RunTests(IEnumerable<string> sources, IRunContext runContext,
     IFrameworkHandle frameworkHandle)
 {
     SetupExecutionPolicy();
     IEnumerable<TestCase> tests = PowerShellTestDiscoverer.GetTests(sources, null);
     RunTests(tests, runContext, frameworkHandle);
 }
开发者ID:vairam-svs,项目名称:poshtools,代码行数:7,代码来源:PowerShellTestExecutor.cs

示例6: RunTests

        public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            ChutzpahTracer.TraceInformation("Begin Test Adapter Run Tests");

            var settingsProvider = runContext.RunSettings.GetSettings(AdapterConstants.SettingsName) as ChutzpahAdapterSettingsProvider;
            var settings = settingsProvider != null ? settingsProvider.Settings : new ChutzpahAdapterSettings();

            ChutzpahTracingHelper.Toggle(settings.EnabledTracing);

            var testOptions = new TestOptions
                {
                    TestLaunchMode =
                        runContext.IsBeingDebugged ? TestLaunchMode.Custom:
                        settings.OpenInBrowser ? TestLaunchMode.FullBrowser:
                        TestLaunchMode.HeadlessBrowser,
                    CustomTestLauncher     = runContext.IsBeingDebugged ? new VsDebuggerTestLauncher() : null,
                    MaxDegreeOfParallelism = runContext.IsBeingDebugged ? 1 : settings.MaxDegreeOfParallelism,
                    ChutzpahSettingsFileEnvironments = new ChutzpahSettingsFileEnvironments(settings.ChutzpahSettingsFileEnvironments)
                };

            testOptions.CoverageOptions.Enabled = runContext.IsDataCollectionEnabled;

            var callback = new ParallelRunnerCallbackAdapter(new ExecutionCallback(frameworkHandle, runContext));
            testRunner.RunTests(sources, testOptions, callback);

            ChutzpahTracer.TraceInformation("End Test Adapter Run Tests");

        }
开发者ID:squadwuschel,项目名称:chutzpah,代码行数:28,代码来源:ChutzpahTestExecutor.cs

示例7: RunTests

        public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            Guard.ArgumentNotNull("sources", sources);
            Guard.ArgumentNotNull("runContext", runContext);
            Guard.ArgumentNotNull("frameworkHandle", frameworkHandle);

            var cleanupList = new List<ExecutorWrapper>();

            try
            {
                RemotingUtility.CleanUpRegisteredChannels();

                cancelled = false;

                foreach (string source in sources)
                    if (VsTestRunner.IsXunitTestAssembly(source))
                        RunTestsInAssembly(cleanupList, source, frameworkHandle);
            }
            finally
            {
                Thread.Sleep(1000);

                foreach (var executorWrapper in cleanupList)
                    executorWrapper.Dispose();
            }
        }
开发者ID:johnkg,项目名称:xunit,代码行数:26,代码来源:VsTestRunner.cs

示例8: RunTests

        public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            //Debugger.Launch();

            frameworkHandle.SendMessage(TestMessageLevel.Informational, Strings.EXECUTOR_STARTING);

            int executedSpecCount = 0;

            Settings settings = GetSettings(runContext);

            string currentAsssembly = string.Empty;
            try
            {

                foreach (IGrouping<string, TestCase> grouping in tests.GroupBy(x => x.Source)) {
                    currentAsssembly = grouping.Key;
                    frameworkHandle.SendMessage(TestMessageLevel.Informational, string.Format(Strings.EXECUTOR_EXECUTINGIN, currentAsssembly));

                    List<VisualStudioTestIdentifier> testsToRun = grouping.Select(test => test.ToVisualStudioTestIdentifier()).ToList();

                    this.executor.RunAssemblySpecifications(currentAsssembly, testsToRun, settings, uri, frameworkHandle);
                    executedSpecCount += grouping.Count();
                }

                frameworkHandle.SendMessage(TestMessageLevel.Informational, String.Format(Strings.EXECUTOR_COMPLETE, executedSpecCount, tests.GroupBy(x => x.Source).Count()));
            } catch (Exception ex)
            {
                frameworkHandle.SendMessage(TestMessageLevel.Error, string.Format(Strings.EXECUTOR_ERROR, currentAsssembly, ex.Message));
            }
            finally
            {
            }
        }
开发者ID:machine-visualstudio,项目名称:machine.vstestadapter,代码行数:33,代码来源:MspecTestAdapterExecutor.cs

示例9: TestCaseFilter

        public TestCaseFilter(IRunContext runContext, ISet<string> traitNames, TestEnvironment testEnvironment)
        {
            _runContext = runContext;
            _testEnvironment = testEnvironment;

            InitProperties(traitNames);
        }
开发者ID:csoltenborn,项目名称:GoogleTestAdapter,代码行数:7,代码来源:TestCaseFilter.cs

示例10: RunTests

        /// <summary>
        /// Runs the tests.
        /// </summary>
        /// <param name="tests">Tests to be run.</param>
        /// <param name="runContext">Context to use when executing the tests.</param>
        /// <param param name="frameworkHandle">Handle to the framework to record results and to do framework operations.</param>
        public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            m_cancelled = false;
            try
            {
                foreach (TestCase test in tests)
                {
                    if (m_cancelled)
                    {
                        break;
                    }
                    frameworkHandle.RecordStart(test);
                    frameworkHandle.SendMessage(TestMessageLevel.Informational, "Starting external test for " + test.DisplayName);
                    var testOutcome = RunExternalTest(test, runContext, frameworkHandle, test);
                    frameworkHandle.RecordResult(testOutcome);
                    frameworkHandle.SendMessage(TestMessageLevel.Informational, "Test result:" + testOutcome.Outcome.ToString());


                }
            }
            catch(Exception e)
            {
                frameworkHandle.SendMessage(TestMessageLevel.Error, "Exception during test execution: " +e.Message);
            }
}
开发者ID:XpiritBV,项目名称:ProtractorAdapter,代码行数:31,代码来源:ProtractorTestExecutor.cs

示例11: RunTests

        public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            this.frameworkHandle = frameworkHandle;

            var testLogger = new TestLogger(frameworkHandle);

            testLogger.SendMainMessage("Execution started");

            foreach (var source in sources)
            {
                try
                {
                    using (var sandbox = new Sandbox<Executor>(source))
                    {
                        testLogger.SendInformationalMessage(String.Format("Running: '{0}'", source));

                        var assemblyDirectory = new DirectoryInfo(Path.GetDirectoryName(source));
                        Directory.SetCurrentDirectory(assemblyDirectory.FullName);
                        sandbox.Content.Execute(this);
                    }
                }
                catch (Exception ex)
                {
                    testLogger.SendErrorMessage(ex, String.Format("Exception found while executing tests in source '{0}'", source));

                    // just go on with the next
                }
            }

            testLogger.SendMainMessage("Execution finished");
        }
开发者ID:laynor,项目名称:NSpecTestAdapter,代码行数:31,代码来源:NSpecExecutor.cs

示例12: RunTests

        public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            frameworkHandle.SendMessage(TestMessageLevel.Informational, Strings.EXECUTOR_STARTING);
            int executedSpecCount = 0;
            string currentAsssembly = string.Empty;
            try
            {
                ISpecificationExecutor specificationExecutor = this.adapterFactory.CreateExecutor();
                IEnumerable<IGrouping<string, TestCase>> groupBySource = tests.GroupBy(x => x.Source);
                foreach (IGrouping<string, TestCase> grouping in groupBySource)
                {
                    currentAsssembly = grouping.Key;
                    frameworkHandle.SendMessage(TestMessageLevel.Informational, string.Format(Strings.EXECUTOR_EXECUTINGIN, currentAsssembly));
                    specificationExecutor.RunAssemblySpecifications(currentAsssembly, MSpecTestAdapter.uri, runContext, frameworkHandle, grouping);
                    executedSpecCount += grouping.Count();
                }

                frameworkHandle.SendMessage(TestMessageLevel.Informational, String.Format(Strings.EXECUTOR_COMPLETE, executedSpecCount, groupBySource.Count()));
            }
            catch (Exception ex)
            {
                frameworkHandle.SendMessage(TestMessageLevel.Error, string.Format(Strings.EXECUTOR_ERROR, currentAsssembly, ex.Message));
            }
            finally
            {
            }
        }
开发者ID:ivanz,项目名称:machine.vstestadapter,代码行数:27,代码来源:MspecTestAdapterExecutor.cs

示例13: RunTests

        /// <summary>
        /// Called by the Visual Studio IDE to run all tests. Also called by TFS Build
        /// to run either all or selected tests. In the latter case, a filter is provided
        /// as part of the run context.
        /// </summary>
        /// <param name="sources">Sources to be run.</param>
        /// <param name="runContext">Context to use when executing the tests.</param>
        /// <param name="frameworkHandle">Test log to send results and messages through</param>
        public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            testLog.Initialize(frameworkHandle);
            Info("executing tests", "started");

            try
            {
                // Ensure any channels registered by other adapters are unregistered
                CleanUpRegisteredChannels();

                var tfsfilter = new TFSTestFilter(runContext);
                testLog.SendDebugMessage("Keepalive:" + runContext.KeepAlive);
                if (!tfsfilter.HasTfsFilterValue && runContext.KeepAlive)
                    frameworkHandle.EnableShutdownAfterTestRun = true;

                foreach (var source in sources)
                {
                    using (currentRunner = new AssemblyRunner(testLog, source, tfsfilter))
                    {
                        currentRunner.RunAssembly(frameworkHandle);
                    }

                    currentRunner = null;
                }
            }
            catch (Exception ex)
            {
                testLog.SendErrorMessage("Exception " + ex);
            }
            finally
            {
                Info("executing tests", "finished");
            }
        }
开发者ID:rprouse,项目名称:nunit-vs-adapter,代码行数:42,代码来源:NUnitTestExecutor.cs

示例14: RunTests

        public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            List<TestCase> tests = new List<TestCase>();

            TestDiscoverer.VisitTests(sources, t => tests.Add(t));

            InternalRunTests(tests, runContext, frameworkHandle, null);
        }
开发者ID:edwardt,项目名称:DreamNJasmine,代码行数:8,代码来源:TestExecutor.cs

示例15: ServersTree

		public ServersTree(IRunContext runContext)
		{
			Context = runContext;
			Children = new ObservableCollection<Node>
			{
				new LocalHostNode(this),
			};
		}
开发者ID:shuralex,项目名称:ProcessControlStandards.OPC,代码行数:8,代码来源:ServersTree.cs


注:本文中的IRunContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。