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


C# TestResult.Failure方法代码示例

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


在下文中一共展示了TestResult.Failure方法的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: Run

        public override TestResult Run(EventListener listener, ITestFilter filter)
        {
            var result = new TestResult(this);

            lock (testClosure) {
                try {
                    testClosure.TestMethod();
                    TestNonExceptionCondition(result);
                } catch (IgnoreException iex) {
                    result.Ignore(iex.Message);
                } catch (InconclusiveException icex) {
                    result.Invalid(icex.Message);
                } catch (Exception ex) {
                    TestExceptionCondition(result, ex);
                }

                try {
                    testClosure.TearDown();
                } catch (Exception ex) {
                    result.Failure("Exception in tear-down: "+ex.Message, ex.StackTrace);
                }
            }

            listener.TestFinished(result);
            return result;
        }
开发者ID:i-e-b,项目名称:FluentBdd,代码行数:26,代码来源:ClosureTest.cs

示例3: DoFixtureSetUp

        public override void DoFixtureSetUp(TestResult suiteResult)
        {
            try
            {
                _fixture.FixtureSetup();

                Status = SetUpState.SetUpComplete;
            }
            catch (Exception ex)
            {
                if (ex is NunitException || ex is TargetInvocationException)
                    ex = ex.InnerException;

                if (testFramework.IsIgnoreException(ex))
                {
                    ShouldRun = false;
                    suiteResult.NotRun(ex.Message);
                    suiteResult.StackTrace = ex.StackTrace;
                    IgnoreReason = ex.Message;
                }
                else
                {
                    suiteResult.Failure(ex.Message, ex.StackTrace);
                    Status = SetUpState.SetUpFailed;
                }
            }
            finally
            {
                if (testFramework != null)
                    suiteResult.AssertCount = testFramework.GetAssertCount();
            }
        }
开发者ID:tiwariritesh7,项目名称:devdefined-tools,代码行数:32,代码来源:PythonFixtureExtension.cs

示例4: Run

 public override TestResult Run(EventListener listener, ITestFilter filter)
 {
     listener.TestStarted(base.TestName);
     long ticks = DateTime.Now.Ticks;
     TestResult testResult = new TestResult(this);
     testResult.Failure(_reason, _stackTrace);
     double num3 = ((double)(DateTime.Now.Ticks - ticks)) / 10000000.0;
     testResult.Time = num3;
     listener.TestFinished(testResult);
     return testResult;
 }
开发者ID:idavis,项目名称:DreamNJasmine,代码行数:11,代码来源:NJasmineInvalidTestSuite.cs

示例5: CreateTestResultFromExpectation

        TestResult CreateTestResultFromExpectation(IExpectation expectation)
        {
            var result = new TestResult(new TestName { Name = expectation.Message });

            if (expectation.IsFail)
                result.Failure(expectation.ToString(), "");
            else if (expectation.IsPass)
                result.Success();
            else if (expectation.IsPending)
                result.Ignore(expectation.ToString(), "");

            return result;
        }
开发者ID:nspec,项目名称:NSpec,代码行数:13,代码来源:TestResultExampleReporter.cs

示例6: RunTestMethod

        public override void RunTestMethod(TestResult testResult)
        {
            using (var runner = new Runner(Spec))
            {
                var example = runner.Run(() => RunBaseTestMethod(testResult), new TestResultExampleReporter(testResult));

                if (example.IsFail)
                    testResult.Failure(GetTestResultMessageForResultState(testResult, ResultState.Failure, "Failing"), "");

                if (example.IsPass)
                    testResult.Success();

                if (example.IsPending)
                    testResult.Ignore(GetTestResultMessageForResultState(testResult, ResultState.Ignored, "Pending"));
            }
        }
开发者ID:AnthonyEgerton,项目名称:NSpec,代码行数:16,代码来源:NSpecTestMethod.cs

示例7: NUnitTestResult

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

            if (concordionResult.HasExceptions)
            {
                testResult.Error(new NUnitException("Exception in Concordion test: please see Concordion test reports"));
            }
            else if (concordionResult.HasFailures)
            {
                testResult.Failure("Concordion Test Failures: " + concordionResult.FailureCount,
                                   "for stack trace, please see Concordion test reports");
            } else
            {
                testResult.Success();
            }

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

示例8: TestExceptionCondition

 private void TestExceptionCondition(TestResult result, Exception ex)
 {
     if (! TestShouldThrowException()) {
         result.Failure("Test or setup failed: "+ex.Message, ex.StackTrace);
     } else {
         if (! ThrownTypeMatchesExpectation(ex)) {
             result.Failure("Expected exception type of "
                            + testClosure.ExpectedExceptionType().Name
                            + " but got " + ex.GetType().Name, "\r\nat\r\n"+ex.StackTrace);
         } else {
             if (! TestExpectsAMessage()) result.Success();
             else {
                 if (ThrownMessageMatchesExpectation(ex)) result.Success();
                 else result.Failure("Expected exception message \r\n\""
                                     + testClosure.ExpectedExceptionMessage()
                                     + "\" but got \r\n\"" + ex.Message, "\"");
             }
         }
     }
 }
开发者ID:i-e-b,项目名称:FluentBdd,代码行数:20,代码来源:ClosureTest.cs

示例9: 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

示例10: DoFixtureTearDown

        public override void DoFixtureTearDown(TestResult suiteResult)
        {
            if (ShouldRun)
            {
                try
                {
                    Status = SetUpState.SetUpNeeded;
                    _fixture.FixtureTeardown();
                }
                catch (Exception ex)
                {
                    NunitException nex = ex as NunitException;
                    if (nex != null)
                        ex = nex.InnerException;

                    suiteResult.Failure(ex.Message, ex.StackTrace);
                }
                finally
                {
                    if (testFramework != null)
                        suiteResult.AssertCount += testFramework.GetAssertCount();
                }
            }
        }
开发者ID:tiwariritesh7,项目名称:devdefined-tools,代码行数:24,代码来源:PythonFixtureExtension.cs

示例11: DoTearDown

		public override void DoTearDown( TestResult suiteResult )
		{
			if (this.ShouldRun) 
			{
				try 
				{
					IsSetUp = false;
					if (this.fixtureTearDown != null)
						Reflect.InvokeMethod(fixtureTearDown, Fixture);
				} 
				catch (Exception ex) 
				{
					// Error in TestFixtureTearDown causes the
					// suite to be marked as a failure, even if
					// all the contained tests passed.
					NunitException nex = ex as NunitException;
					if (nex != null)
						ex = nex.InnerException;

					suiteResult.Failure( ex.Message, ex.StackTrace);
				}
				finally
				{
					suiteResult.AssertCount += NUnit.Framework.Assert.Counter;
				}
			}

			if (this.IgnoreReason == FIXTURE_SETUP_FAILED) 
			{
				this.ShouldRun = true;
				this.IgnoreReason = null;
			}
		}
开发者ID:alesliehughes,项目名称:olive,代码行数:33,代码来源:TestFixture.cs

示例12: RecordException

 protected void RecordException(Exception ex, TestResult testResult)
 {
     if (testFramework.IsIgnoreException(ex))
         testResult.NotRun(ex.Message);
     else if (testFramework.IsAssertException(ex))
         testResult.Failure(ex.Message, ex.StackTrace);
     else
         testResult.Failure(BuildMessage(ex), BuildStackTrace(ex));
 }
开发者ID:tiwariritesh7,项目名称:devdefined-tools,代码行数:9,代码来源:PythonTestMethod.cs

示例13: MarkTestFailed

        private void MarkTestFailed(
            Test test, TestResult suiteResult, EventListener listener, ITestFilter filter)
        {
            if (test is TestSuite)
            {
                listener.SuiteStarted(test.TestName);
                TestResult result = new TestResult( new TestInfo(test) );
				string msg = this.FixtureType == null
                    ? "Parent SetUp failed"
                    : string.Format( "Parent SetUp failed in {0}", this.FixtureType.Name );

				result.Failure(msg, null, FailureSite.Parent);
                MarkTestsFailed(test.Tests, result, listener, filter);
                suiteResult.AddResult(result);
                listener.SuiteFinished(result);
            }
            else
            {
                listener.TestStarted(test.TestName);
                TestResult result = new TestResult( new TestInfo(test) );
				string msg = this.FixtureType == null
                    ? "TestFixtureSetUp failed"
                    : string.Format( "TestFixtureSetUp failed in {0}", this.FixtureType.Name );
				result.Failure(msg, null, FailureSite.Parent);
				suiteResult.AddResult(result);
                listener.TestFinished(result);
            }
        }
开发者ID:kobida,项目名称:nunitv2,代码行数:28,代码来源:TestSuite.cs

示例14: DoOneTimeAfterTestSuiteActions

        protected virtual void DoOneTimeAfterTestSuiteActions(TestResult suiteResult)
        {
            try
            {
                ExecuteActions(ActionPhase.After);
            }
            catch (Exception ex)
            {
                // Error in TestFixtureTearDown or Dispose causes the
                // suite to be marked as a failure, even if
                // all the contained tests passed.
                NUnitException nex = ex as NUnitException;
                if (nex != null)
                    ex = nex.InnerException;

                suiteResult.Failure(ex.Message, ex.StackTrace, FailureSite.TearDown);
            }
        }
开发者ID:kobida,项目名称:nunitv2,代码行数:18,代码来源:TestSuite.cs

示例15: DoOneTimeTearDown

        protected virtual void DoOneTimeTearDown(TestResult suiteResult)
        {
            if ( this.RunState == RunState.Runnable && this.Fixture != null)
            {
                try
                {
                    if (this.fixtureTearDown != null)
                        Reflect.InvokeMethod(fixtureTearDown, Fixture);
                }
                catch (Exception ex)
                {
                    // Error in TestFixtureTearDown causes the
                    // suite to be marked as a failure, even if
                    // all the contained tests passed.
                    NUnitException nex = ex as NUnitException;
                    if (nex != null)
                        ex = nex.InnerException;

                    suiteResult.Failure(ex.Message, ex.StackTrace, FailureSite.TearDown);
                }
                finally
                {
                    IDisposable disposeable = Fixture as IDisposable;
                    if (disposeable != null)
                        disposeable.Dispose();
                    this.Fixture = null;
                }
            }
        }
开发者ID:fotisp,项目名称:conqat,代码行数:29,代码来源:TestSuite.cs


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