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


C# TestResult.SetResult方法代码示例

本文整理汇总了C#中NUnit.Core.TestResult.SetResult方法的典型用法代码示例。如果您正苦于以下问题:C# TestResult.SetResult方法的具体用法?C# TestResult.SetResult怎么用?C# TestResult.SetResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NUnit.Core.TestResult的用法示例。


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

示例1: RunTest

        TestResult RunTest(EventListener listener)
        {
            listener.TestStarted(base.TestName);

            TestResult nunitTestResult = new TestResult(this);

            if (_pendingException != null)
            {
                nunitTestResult.Failure(_pendingException.Message, _pendingException.StackTrace, FailureSite.Test);
            }
            else if (RunState == RunState.NotRunnable)
            {
                nunitTestResult.SetResult(ResultState.NotRunnable, IgnoreReason, "", FailureSite.Test);
            }
            else
            {
                var testResult = SpecificationRunner.RunTest(this._testContext, new List<string>());

                NativeTestResult.ApplyToNunitResult(testResult, nunitTestResult);
            }

            listener.TestFinished(nunitTestResult);

            return nunitTestResult;
        }
开发者ID:edwardt,项目名称:DreamNJasmine,代码行数:25,代码来源:NJasmineTestMethod.cs

示例2: WhenResultIsSet_IndexReflectsResultState

        public void WhenResultIsSet_IndexReflectsResultState(ResultState resultState, int expectedIndex)
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode(new TestInfo(testCase));
            TestResult result = new TestResult(testCase);

            result.SetResult(resultState, null, null);
            node.Result = result;
            Assert.AreEqual(expectedIndex, node.ImageIndex);
            Assert.AreEqual(expectedIndex, node.SelectedImageIndex);
            Assert.AreEqual(resultState.ToString(), node.StatusText);
        }
开发者ID:kobida,项目名称:nunitv2,代码行数:11,代码来源:TestSuiteTreeNodeTests.cs

示例3: Run

 public override TestResult Run(EventListener listener, ITestFilter filter)
 {
     listener.TestStarted(base.TestName);
     long ticks = DateTime.Now.Ticks;
     TestResult result = new TestResult(this);
     result.SetResult(ResultState.NotRunnable, "Specification not implemented.", null, FailureSite.Test);
     double num3 = ((double)(DateTime.Now.Ticks - ticks)) / 10000000.0;
     result.Time = num3;
     listener.TestFinished(result);
     return result;
 }
开发者ID:idavis,项目名称:DreamNJasmine,代码行数:11,代码来源:NJasmineUnimplementedTestMethod.cs

示例4: SetResult_Inconclusive

        public void SetResult_Inconclusive()
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode(testCaseInfo);
            TestResult result = new TestResult(testCaseInfo);

            result.SetResult(ResultState.Inconclusive, null, null);
            node.Result = result;
            Assert.AreEqual("MockTest1", node.Result.Name);
            Assert.AreEqual(TestSuiteTreeNode.InconclusiveIndex, node.ImageIndex);
            Assert.AreEqual(TestSuiteTreeNode.InconclusiveIndex, node.SelectedImageIndex);
            Assert.AreEqual(result.ResultState.ToString(), node.StatusText);
        }
开发者ID:Vernathic,项目名称:ic-AutoTest.NET4CTDD,代码行数:12,代码来源:TestSuiteTreeNodeTests.cs

示例5: Run

        public override TestResult Run(EventListener listener, ITestFilter filter)
        {
            // TODO: Implement logic required for filtering.

            listener.TestStarted(this.TestName);
            long startTime = DateTime.Now.Ticks;

            var result = new TestResult(this);

            try
            {
                _engine.ExecuteScriptFile(_scriptPath);
                result.Success();
            }
            catch (AssertionException assertEx)
            {
                result.SetResult(ResultState.Failure, assertEx.Message, assertEx.StackTrace, FailureSite.Test);
            }
            catch (InconclusiveException inconclusiveEx)
            {
                result.SetResult(ResultState.Inconclusive, inconclusiveEx.Message, inconclusiveEx.StackTrace);
            }
            catch (Exception ex)
            {
                result.Error(ex);
            }
            finally
            {
                long stopTime = DateTime.Now.Ticks;
                double time = ((double)(stopTime - startTime)) / (double)TimeSpan.TicksPerSecond;
                result.Time = time;

                listener.TestFinished(result);
            }

            return result;
        }
开发者ID:rablewis,项目名称:NuScript,代码行数:37,代码来源:ScriptTest.cs

示例6: CreateTestResult

        public TestResult CreateTestResult(TestType type, string fullName,
                                           ResultState state = ResultState.Success, 
                                           Func<IEnumerable<TestResult>> children = null, 
                                           string stackTrace = null, 
                                           string description = null,
                                           IList categories = null,
                                           string agentName = null)
        {
            description = description ?? RandomValuesGenerator.GetRandomValue<string>();
            agentName = agentName ?? RandomValuesGenerator.GetRandomValue<string>();
            var splitted = (fullName ?? string.Empty).Split(new[]{'.'}, StringSplitOptions.RemoveEmptyEntries);

            var childResults = children != null ? children() : new TestResult[0];
            var testResult = new TestResult(new TestInfoWrapper
                                                {
                                                    TestName = new TestName
                                                                   {
                                                                       FullName = fullName,
                                                                       Name = splitted.Length > 0 ? splitted[splitted.Length - 1] : string.Empty
                                                                   },
                                                    Categories = categories,
                                                    IsSuite = type != TestType.TestMethod,
                                                    TestCount = type == TestType.TestMethod ? 1 : RandomValuesGenerator.GetRandomValue<int>(),
                                                    TestType = type.ToString()
                                                })
                                 {
                                     AssertCount = 1,
                                     Time = RandomValuesGenerator.GetRandomValue<double>()
                                 };
            if (state != ResultState.Success)
                testResult.SetResult(state,
                                     description,
                                     stackTrace);
            else
                testResult.Success(description);

            testResult.SetAgentName(agentName);

            foreach (var childResult in childResults)
            {
                testResult.AddResult(childResult);
            }

            return testResult;
        }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:45,代码来源:TestEntitiesGenerator.cs

示例7: ApplyToNunitResult

        public static TestResult ApplyToNunitResult(TestResultShim shim, TestResult result)
        {
            switch (shim.Status)
            {
                case TestResultShim.Result.Successs:
                    result.Success();
                    break;
                case TestResultShim.Result.Error:
                    result.SetResult(ResultState.Error, shim.FailureReason, shim.FailureStackTrace, GetNUnitFailureSite(shim.FailureSite));
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            result.Time = shim.ExecutionTime.Seconds;

            return result;
        }
开发者ID:edwardt,项目名称:DreamNJasmine,代码行数:18,代码来源:NativeTestResult.cs

示例8: SetUp

        public void SetUp()
        {
            MethodInfo fakeTestMethod = GetType().GetMethod("FakeTestMethod", BindingFlags.Instance | BindingFlags.NonPublic);
            fakeNUnitTest = new NUnitTestMethod(fakeTestMethod);

            fakeNUnitResult = new NUnitTestResult(fakeNUnitTest);
            fakeNUnitResult.SetResult(ResultState.Success, "It passed!", null);
            fakeNUnitResult.Time = 1.234;

            testLog = new FakeFrameworkHandle();

            testConverter = new TestConverter(new TestLogger(), ThisAssemblyPath);

            testConverter.ConvertTestCase(fakeNUnitTest);
            Assert.NotNull(testConverter.GetCachedTestCase(fakeNUnitTest.TestName.UniqueName));

            listener = new NUnitEventListener(testLog, testConverter);
        }
开发者ID:kukubadze,项目名称:nunit-vs-adapter,代码行数:18,代码来源:NUnitEventListenerTests.cs

示例9: CanMakeTestResultFromNUnitTestResult

        public void CanMakeTestResultFromNUnitTestResult()
        {
            // This should put the TestCase in the cache
            var cachedTestCase = testConverter.ConvertTestCase(fakeNUnitTest);

            var nunitResult = new NUnitTestResult(fakeNUnitTest);
            nunitResult.SetResult(ResultState.Success, "It passed!", null);
            nunitResult.Time = 1.234;

            var testResult = testConverter.ConvertTestResult(nunitResult);
            var testCase = testResult.TestCase;

            Assert.That(testCase, Is.SameAs(cachedTestCase));

            CheckTestCase(testCase);

            Assert.That(testResult.Outcome, Is.EqualTo(TestOutcome.Passed));
            Assert.That(testResult.ErrorMessage, Is.EqualTo("It passed!"));
            Assert.That(testResult.Duration, Is.EqualTo(TimeSpan.FromSeconds(1.234)));
        }
开发者ID:rprouse,项目名称:nunit-vs-adapter,代码行数:20,代码来源:TestConverterTests.cs

示例10: NUnitTestResult

        private TestResult NUnitTestResult(IResultSummary concordionResult, string resultPath)
        {
            var testResult = new TestResult(this);

            if (concordionResult.HasExceptions)
            {
                var errorDetails = concordionResult.ErrorDetails.First();
                testResult.Error(errorDetails.Exception);
                testResult.SetResult(testResult.ResultState,
                                     resultPath + Environment.NewLine + testResult.Message,
                                     testResult.StackTrace);
            }
            else if (concordionResult.HasFailures)
            {
                var failureDetails = concordionResult.FailureDetails.First();
                testResult.Failure(resultPath + Environment.NewLine + failureDetails.Message, failureDetails.StackTrace);
            } else
            {
                testResult.Success(resultPath);
            }

            return testResult;
        }
开发者ID:concordion,项目名称:concordion-net,代码行数:23,代码来源:ConcordionTest.cs

示例11: GetNoAvailableAgentsFailure

        /// <summary>
        /// Gets the no available agents failure.
        /// </summary>
        /// <param name="test">The test.</param>
        /// <param name="exception">The exception.</param>
        /// <returns></returns>
        public static TestResult GetNoAvailableAgentsFailure(TestUnitWithMetadata test, Exception exception)
        {
            var result = GetResultForTest(test.Test, exception);
            TestResult suite = result;

            while (suite.HasResults)
            {
                suite = (TestResult)suite.Results[0];
            }

            // A test can be either test suite or test case
            // Here it is a suite
            if (test.Test.Info.IsSuite && test.Children.Any())
            {
                foreach (var child in test.Children)
                {
                    var childResult = new TestResult(child.Test.Info);
                    childResult.SetResult(ResultState.NotRunnable, exception, FailureSite.Parent);
                    suite.AddResult(childResult);
                }
            }

            return result;
        }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:30,代码来源:TestResultFactory.cs

示例12: RecordException

		protected virtual void RecordException( Exception exception, TestResult testResult, FailureSite failureSite )
		{
            if (exception is NUnitException)
                exception = exception.InnerException;

            // Ensure that once a test is cancelled, it stays cancelled
            ResultState finalResultState = testResult.ResultState == ResultState.Cancelled
                ? ResultState.Cancelled
                : NUnitFramework.GetResultState(exception);

            testResult.SetResult(finalResultState, exception, failureSite);
		}
开发者ID:Buildstarted,项目名称:ContinuousTests,代码行数:12,代码来源:TestMethod.cs

示例13: RunTest

		/// <summary>
		/// The doRun method is used to run a test internally.
		/// It assumes that the caller is taking care of any 
		/// TestFixtureSetUp and TestFixtureTearDown needed.
		/// </summary>
		/// <param name="testResult">The result in which to record success or failure</param>
		public virtual TestResult RunTest()
		{
			DateTime start = DateTime.Now;

			TestResult testResult = new TestResult(this);
			TestExecutionContext.CurrentContext.CurrentResult =  testResult;
			
			try
			{
                RunSetUp();
#if CLR_2_0 || CLR_4_0
			    RunBeforeActions(testResult);
#endif

				RunTestCase( testResult );
			}
			catch(Exception ex)
			{
                // doTestCase handles its own exceptions so
                // if we're here it's a setup exception
                if (ex is ThreadAbortException)
                    Thread.ResetAbort();

                RecordException(ex, testResult, FailureSite.SetUp);
			}
			finally 
			{
#if CLR_2_0 || CLR_4_0
                RunAfterActions(testResult);
#endif
				RunTearDown( testResult );

				DateTime stop = DateTime.Now;
				TimeSpan span = stop.Subtract(start);
				testResult.Time = (double)span.Ticks / (double)TimeSpan.TicksPerSecond;

                if (testResult.IsSuccess)
				{
					if (this.Properties.Contains("MaxTime"))
                	{
                    int elapsedTime = (int)Math.Round(testResult.Time * 1000.0);
                    int maxTime = (int)this.Properties["MaxTime"];

                    if (maxTime > 0 && elapsedTime > maxTime)
                        testResult.Failure(
                            string.Format("Elapsed time of {0}ms exceeds maximum of {1}ms",
                                elapsedTime, maxTime),
                            null);
					}
					
					if (testResult.IsSuccess && testResult.Message == null && 
					    Environment.CurrentDirectory != TestExecutionContext.CurrentContext.prior.CurrentDirectory)
					{
						// TODO: Introduce a warning result state in NUnit 3.0
						testResult.SetResult(ResultState.Success, "Warning: Test changed the CurrentDirectory", null);
					}
				}
			}
			
			log.Debug("Test result = " + testResult.ResultState);
				
			return testResult;
		}
开发者ID:Buildstarted,项目名称:ContinuousTests,代码行数:69,代码来源:TestMethod.cs

示例14: GetResult

        /// <summary>
        /// Gets the result.
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <param name="description">The description.</param>
        /// <param name="testType">Type of the test.</param>
        /// <param name="fullName">The full name.</param>
        /// <param name="isSuite">if set to <c>true</c> [is suite].</param>
        /// <returns></returns>
        public static TestResult GetResult(Exception exception, string description, string testType, string fullName, bool isSuite = true)
        {
            var result = new TestResult(new TestDataProvider
                                            {
                                                TestName = new TestName
                                                               {
                                                                   FullName = fullName,
                                                                   Name = fullName
                                                               },
                                                IsSuite = isSuite,
                                                TestType = testType,
                                            });
            result.SetResult(ResultState.NotRunnable,
                exception == null ? description : exception.Message,
                exception == null ? null : exception.StackTrace);

            return result;
        }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:27,代码来源:TestResultFactory.cs

示例15: RecordException

        protected virtual void RecordException( Exception exception, TestResult testResult, FailureSite failureSite )
        {
            if (exception is NUnitException)
                exception = exception.InnerException;

            testResult.SetResult(NUnitFramework.GetResultState(exception), exception, failureSite);
        }
开发者ID:scottwis,项目名称:eddie,代码行数:7,代码来源:TestMethod.cs


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