• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ITestCommand类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: RunContext

        private TestResult RunContext( NSpecContextTest contextTest, ITestCommand command, TestStep testStep )
        {
            ITestContext testContext = command.StartPrimaryChildStep( testStep );
            TestOutcome outcome = TestOutcome.Passed;

            foreach( ITestCommand testCommand in command.Children )
            {
                NSpecExampleTest exampleTest = testCommand.Test as NSpecExampleTest;
                if( exampleTest == null )
                {
                    continue;
                }
                outcome = outcome.CombineWith( this.RunTest( contextTest, exampleTest, testCommand, testContext.TestStep ).Outcome );
            }
            foreach( ITestCommand testCommand in command.Children )
            {
                NSpecContextTest contextTestChild = testCommand.Test as NSpecContextTest;
                if( contextTestChild == null )
                {
                    continue;
                }
                outcome = outcome.CombineWith( this.RunContext( contextTestChild, testCommand, testContext.TestStep ).Outcome );
            }

            return testContext.FinishStep( outcome, null );
        }
开发者ID:JosephJung,项目名称:NSpec,代码行数:26,代码来源:NSpecController.cs


示例2: RunTest

        private TestResult RunTest(ITestCommand testCommand, TestStep parentTestStep, IProgressMonitor progressMonitor)
        {
            Test test = testCommand.Test;
            progressMonitor.SetStatus(test.Name);

            // The first test should be an assembly test
            MSTestAssembly assemblyTest = testCommand.Test as MSTestAssembly;
            TestOutcome outcome;
            TestResult result;
            if (assemblyTest != null)
            {
                ITestContext assemblyContext = testCommand.StartPrimaryChildStep(parentTestStep);
                try
                {
                    MSTestRunner runner = MSTestRunner.GetRunnerForFrameworkVersion(frameworkVersion);

                    outcome = runner.RunSession(assemblyContext, assemblyTest,
                        testCommand, parentTestStep, progressMonitor);
                }
                catch (Exception ex)
                {
                    assemblyContext.LogWriter.Failures.WriteException(ex, "Internal Error");
                    outcome = TestOutcome.Error;
                }

                result = assemblyContext.FinishStep(outcome, null);
            }
            else
            {
                result = new TestResult(TestOutcome.Skipped);
            }

            progressMonitor.Worked(1);
            return result;
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:35,代码来源:MSTestController.cs


示例3: RunImpl

        protected override TestResult RunImpl( ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor )
        {
            using(progressMonitor.BeginTask( "Verifying Specifications", rootTestCommand.TestCount ) )
            {
                if( options.SkipTestExecution )
                {
                    return SkipAll( rootTestCommand, parentTestStep );
                }
                else
                {
                    ITestContext rootContext = rootTestCommand.StartPrimaryChildStep( parentTestStep );
                    TestStep rootStep = rootContext.TestStep;
                    TestOutcome outcome = TestOutcome.Passed;

                    foreach( ITestCommand command in rootTestCommand.Children )
                    {
                        NSpecAssemblyTest assemblyTest = command.Test as NSpecAssemblyTest;
                        if( assemblyTest == null )
                            continue;

                        var assemblyResult = this.RunAssembly( command, rootStep );
                        outcome = outcome.CombineWith( assemblyResult.Outcome );
                    }

                    return rootContext.FinishStep( outcome, null );
                }
            }
        }
开发者ID:JosephJung,项目名称:NSpec,代码行数:28,代码来源:NSpecController.cs


示例4: RunImpl

        /// <inheritdoc />
        protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
        {
            ThrowIfDisposed();

            using (progressMonitor.BeginTask(Resources.MbUnit2TestController_RunningMbUnitTests, 1))
            {
                if (progressMonitor.IsCanceled)
                    return new TestResult(TestOutcome.Canceled);

                if (options.SkipTestExecution)
                {
                    return SkipAll(rootTestCommand, parentTestStep);
                }
                else
                {
                    IList<ITestCommand> testCommands = rootTestCommand.GetAllCommands();

                    using (InstrumentedFixtureRunner fixtureRunner = new InstrumentedFixtureRunner(fixtureExplorer,
                        testCommands, progressMonitor, parentTestStep))
                    {
                        return fixtureRunner.Run();
                    }
                }
            }
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:26,代码来源:MbUnit2TestController.cs


示例5: RunImpl

 protected internal override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
 {
     using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount))
     {
         return RunTest(rootTestCommand, parentTestStep, options, progressMonitor);
     }
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:7,代码来源:DelegatingTestController.cs


示例6: RunImpl

        protected internal override TestResult RunImpl(ITestCommand rootTestCommand, Model.Tree.TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
        {
            using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount))
            {
                // Note: We do not check options.SkipTestExecution here because we want to build up
                // the tree of data-driven test steps.  So we actually check it later on in the
                // PatternTestExecutor.  This is different from framework adapters
                // at this time (because they do not generally support dynamically generated data-driven tests).
                Sandbox sandbox = new Sandbox();
                EventHandler canceledHandler = delegate { sandbox.Abort(TestOutcome.Canceled, "The user canceled the test run."); };
                try
                {
                    progressMonitor.Canceled += canceledHandler;

                    TestAssemblyExecutionParameters.Reset();

                    PatternTestExecutor executor = new PatternTestExecutor(options, progressMonitor, formatter, converter, environmentManager);

                    // Inlined to minimize stack depth.
                    var action = executor.CreateActionToRunTest(rootTestCommand, parentTestStep, sandbox, null);
                    action.Run();
                    return action.Result;
                }
                finally
                {
                    progressMonitor.Canceled -= canceledHandler;
                    sandbox.Dispose();
                }
            }
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:30,代码来源:PatternTestController.cs


示例7: SetUp

 public void SetUp()
 {
     testCommand = MockRepository.GenerateStub<ITestCommand>();
     testName = new TestName { TestID = new TestID(), FullName = "fullName" };
     var testCommandsByTestName = new Dictionary<TestName, ITestCommand> { { testName, testCommand } };
     testFilter = new NUnitTestFilter(testCommandsByTestName);
     test = MockRepository.GenerateStub<ITest>();
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:8,代码来源:NUnitTestFilterTest.cs


示例8: NuwaTestCommand

        public NuwaTestCommand(ITestCommand innerCommand)
        {
            if (innerCommand == null)
            {
                throw new ArgumentNullException("innerCommand");
            }

            _proxy = innerCommand;
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:9,代码来源:NuwaTestCommand.cs


示例9: OnTestStart

        static bool OnTestStart(ITestCommand command, ExecutorCallback callback)
        {
            XmlNode node = command.ToStartXml();

            if (node != null)
                callback.Notify(node.OuterXml);

            return callback.ShouldContinue();
        }
开发者ID:nulltoken,项目名称:xunit,代码行数:9,代码来源:Executor.cs


示例10: RunChildTests

        private static TestResult RunChildTests(ITestCommand testCommand, TestStep parentTestStep, IProgressMonitor progressMonitor)
        {
            ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep);

            bool passed = true;
            foreach (ITestCommand child in testCommand.Children)
                passed &= RunTest(child, testContext.TestStep, progressMonitor).Outcome.Status == TestStatus.Passed;

            return testContext.FinishStep(passed ? TestOutcome.Passed : TestOutcome.Failed, null);
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:10,代码来源:XunitTestController.cs


示例11: RunAll

 private void RunAll(IProgressMonitor progressMonitor, ITestCommand rootTestCommand)
 {
     using (var subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1))
     {
         using (subProgressMonitor.BeginTask("Running the tests.", rootTestCommand.TestCount))
         {
             RunTest(rootTestCommand, null, subProgressMonitor);
         }
     }
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:10,代码来源:RunTask.cs


示例12: Run

        /// <summary>
        /// Runs the tests.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This method can be called at most once during the lifetime of a test controller.
        /// </para>
        /// </remarks>
        /// <param name="rootTestCommand">The root test monitor.</param>
        /// <param name="parentTestStep">The parent test step, or null if starting a root step.</param>
        /// <param name="options">The test execution options.</param>
        /// <param name="progressMonitor">The progress monitor.</param>
        /// <returns>The combined result of the root test command.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="rootTestCommand"/>
        /// <paramref name="progressMonitor"/>, or <paramref name="options"/> is null.</exception>
        public TestResult Run(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
        {
            if (rootTestCommand == null)
                throw new ArgumentNullException("rootTestCommand");
            if (progressMonitor == null)
                throw new ArgumentNullException("progressMonitor");
            if (options == null)
                throw new ArgumentNullException("options");

            return RunImpl(rootTestCommand, parentTestStep, options, progressMonitor);
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:26,代码来源:TestController.cs


示例13: WrapsPassedInCommandIntoFixtureCommand

        public void WrapsPassedInCommandIntoFixtureCommand([Frozen] Dictionary<MethodInfo, object> fixtures, FixtureSet sut, ITestCommand command)
        {
            var result = sut.ApplyFixturesToCommand(command);

            Assert.IsType<FixtureCommand>(result);
            var fixtureCommand = (FixtureCommand) result;
            Assert.Same(command, fixtureCommand.InnerCommand);

            //can't do anything else since fixtures property is not exposed
            var savedFixtures = typeof (FixtureCommand).GetField("fixtures", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(fixtureCommand);
            Assert.Same(fixtures, savedFixtures);
        }
开发者ID:fulviogabana,项目名称:xUnit.Paradigms,代码行数:12,代码来源:FixtureSetTests.cs


示例14: OnTestStart

        static bool OnTestStart(ITestCommand command, ICallbackEventHandler callback)
        {
            if (callback == null)
                return true;

            XmlNode node = command.ToStartXml();

            if (node != null)
                callback.RaiseCallbackEvent(node.OuterXml);

            return bool.Parse(callback.GetCallbackResult());
        }
开发者ID:chrisortman,项目名称:coulda,代码行数:12,代码来源:Executor.cs


示例15: RunTest

        private TestResult RunTest(ITestCommand testCommand, TestStep parentTestStep,
            TestExecutionOptions options, IProgressMonitor progressMonitor)
        {
            // NOTE: This method has been optimized to minimize the total stack depth of the action
            //       by inlining blocks on the critical path that had previously been factored out.

            using (TestController testController = testControllerProvider(testCommand.Test))
            {
                if (testController != null)
                {
                    try
                    {
                        using (IProgressMonitor subProgressMonitor = progressMonitor.CreateSubProgressMonitor(testCommand.TestCount))
                        {
                            // Calling RunImpl directly instead of Run to minimize stack depth
                            // because we already know the arguments are valid.
                            return testController.RunImpl(testCommand, parentTestStep, options, subProgressMonitor);
                        }
                    }
                    catch (Exception ex)
                    {
                        ITestContext context = testCommand.StartPrimaryChildStep(parentTestStep);
                        context.LogWriter.Failures.WriteException(ex, "Fatal Exception in test controller");
                        return context.FinishStep(TestOutcome.Error, null);
                    }
                }
            }

            // Enter the scope of the test and recurse until we find a controller.
            progressMonitor.SetStatus(testCommand.Test.FullName);

            ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep);
            TestOutcome outcome = TestOutcome.Passed;

            foreach (ITestCommand monitor in testCommand.Children)
            {
                if (progressMonitor.IsCanceled)
                    break;

                TestResult childResult = RunTest(monitor, testContext.TestStep, options, progressMonitor);
                outcome = outcome.CombineWith(childResult.Outcome).Generalize();
            }

            if (progressMonitor.IsCanceled)
                outcome = TestOutcome.Canceled;

            TestResult result = testContext.FinishStep(outcome, null);

            progressMonitor.Worked(1);
            return result;
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:51,代码来源:DelegatingTestController.cs


示例16: RunImpl

 protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
 {
     using (progressMonitor.BeginTask(Resources.XunitTestController_RunningXunitTests, rootTestCommand.TestCount))
     {
         if (options.SkipTestExecution)
         {
             return SkipAll(rootTestCommand, parentTestStep);
         }
         else
         {
             return RunTest(rootTestCommand, parentTestStep, progressMonitor);
         }
     }
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:14,代码来源:XunitTestController.cs


示例17: RunSession

        public TestOutcome RunSession(ITestContext assemblyTestContext, MSTestAssembly assemblyTest,
            ITestCommand assemblyTestCommand, TestStep parentTestStep, IProgressMonitor progressMonitor)
        {
            DirectoryInfo tempDir = SpecialPathPolicy.For("MSTestAdapter").CreateTempDirectoryWithUniqueName();
            try
            {
                // Set the test results path.  Among other things, the test results path
                // will determine where the deployed test files go.
                string testResultsPath = Path.Combine(tempDir.FullName, "tests.trx");

                // Set the test results root directory.
                // This path determines both where MSTest searches for test files which
                // is used to resolve relative paths to test files in the "*.vsmdi" file.
                string searchPathRoot = Path.GetDirectoryName(assemblyTest.AssemblyFilePath);

                // Set the test metadata and run config paths.  These are just temporary
                // files that can go anywhere on the filesystem.  It happens to be convenient
                // to store them in the same temporary directory as the test results.
                string testMetadataPath = Path.Combine(tempDir.FullName, "tests.vsmdi");
                string runConfigPath = Path.Combine(tempDir.FullName, "tests.runconfig");

                progressMonitor.SetStatus("Generating test metadata file.");
                CreateTestMetadataFile(testMetadataPath,
                    GetTestsFromCommands(assemblyTestCommand.PreOrderTraversal), assemblyTest.AssemblyFilePath);

                progressMonitor.SetStatus("Generating run config file.");
                CreateRunConfigFile(runConfigPath);

                progressMonitor.SetStatus("Executing tests.");
                Executor executor = new Executor(this, assemblyTestContext, assemblyTestCommand);
                TestOutcome outcome = executor.Execute(testMetadataPath, testResultsPath,
                    runConfigPath, searchPathRoot);
                return outcome;
            }
            finally
            {
                try
                {
                    tempDir.Delete(true);
                }
                catch
                {
                    // Ignore I/O exceptions deleting temporary files.
                    // They will probably be deleted by the OS later on during a file cleanup.
                }
            }
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:47,代码来源:MSTestRunner.cs


示例18: RunTestsInternal

    protected override void RunTestsInternal(ITestCommand rootTestCommand, ITestStep parentTestStep,
                                             TestExecutionOptions options, IProgressMonitor progressMonitor)
    {
      using (progressMonitor)
      {
        progressMonitor.BeginTask("Verifying Specifications", rootTestCommand.TestCount);

        if (options.SkipTestExecution)
        {
          SkipAll(rootTestCommand, parentTestStep);
        }
        else
        {
          RunTest(rootTestCommand, parentTestStep, progressMonitor);
        }
      }
    }
开发者ID:benlovell,项目名称:machine.specifications,代码行数:17,代码来源:MachineSpecificationController.cs


示例19: RunImpl

        /// <inheritdoc />
        protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
        {
            using (progressMonitor.BeginTask(Resources.ConcordionTestController_RunningConcordionTests, rootTestCommand.TestCount))
            {
                if (progressMonitor.IsCanceled)
                    return new TestResult(TestOutcome.Canceled);

                if (options.SkipTestExecution)
                {
                    return SkipAll(rootTestCommand, parentTestStep);
                }
                else
                {
                    return RunTest(rootTestCommand, parentTestStep, progressMonitor);
                }
            }
        }
开发者ID:john-ross,项目名称:concordion-net,代码行数:18,代码来源:ConcordionTestController.cs


示例20: RunTestFixture

        private static TestResult RunTestFixture(ITestCommand testCommand, ConcordionTest concordionTest, TestStep parentTestStep)
        {
            ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep);

            // The magic happens here!
            var concordion = new ConcordionBuilder()
                                    .WithSource(concordionTest.Source)
                                    .WithTarget(concordionTest.Target)
                                    .WithSpecificationProcessingListener(new GallioResultRenderer())
                                    .Build();

            ConstructorInfo constructor = concordionTest.FixtureType.GetConstructor(Type.EmptyTypes);
            var fixture=constructor.Invoke(new object[]{});
            var summary = concordion.Process(concordionTest.Resource, fixture);
            bool passed = !(summary.HasFailures || summary.HasExceptions);
            testContext.AddAssertCount((int)summary.SuccessCount + (int)summary.FailureCount);
            return testContext.FinishStep(passed ? TestOutcome.Passed : TestOutcome.Failed, null);
        }
开发者ID:john-ross,项目名称:concordion-net,代码行数:18,代码来源:ConcordionTestController.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ITestContext类代码示例发布时间:2022-05-24
下一篇:
C# ITestClass类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap