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


C# Core.TestResult类代码示例

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


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

示例1: TestFinished

        public void TestFinished(TestResult result)
        {
            totalAssertsExecutedInThisRun = totalAssertsExecutedInThisRun + result.AssertCount;

            if (!result.IsSuccess)
                totalAssertsExecutedInThisRun++;
        }
开发者ID:fperezpt,项目名称:NUnitExtensions,代码行数:7,代码来源:CountExecutedAsserts.cs

示例2: Run

        public override TestResult Run(EventListener listener, ITestFilter filter)
        {
            using (new global::NUnit.Core.TestContext())
            {
                var testResult = new TestResult(this);
                Log.Debug("Test Starting: " + TestName.FullName);
                listener.TestStarted(TestName);
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                switch (RunState)
                {
                    case RunState.Runnable:
                    case RunState.Explicit:
                        DoTest(_test, testResult);
                        break;
                    case RunState.NotRunnable:
                        testResult.Invalid(IgnoreReason);
                        break;
                    case RunState.Ignored:
                        testResult.Ignore(IgnoreReason);
                        break;
                    default:
                        testResult.Skip(IgnoreReason);
                        break;

                }

                stopwatch.Stop();
                testResult.Time = stopwatch.Elapsed.Seconds;

                listener.TestFinished(testResult);
                return testResult;
            }
        }
开发者ID:WalkingDisaster,项目名称:Lingual,代码行数:35,代码来源:LingualTest.cs

示例3: ConvertTestResult

        public VSTestResult ConvertTestResult(NUnitTestResult result)
        {
            TestCase ourCase = GetCachedTestCase(result.Test.TestName.UniqueName);
            if (ourCase == null) return null;

            VSTestResult ourResult = new VSTestResult(ourCase)
                {
                    DisplayName = ourCase.DisplayName,
                    Outcome = ResultStateToTestOutcome(result.ResultState),
                    Duration = TimeSpan.FromSeconds(result.Time)
                };

            // TODO: Remove this when NUnit provides a better duration
            if (ourResult.Duration == TimeSpan.Zero && (ourResult.Outcome == TestOutcome.Passed || ourResult.Outcome == TestOutcome.Failed))
                ourResult.Duration = TimeSpan.FromTicks(1);
            ourResult.ComputerName = Environment.MachineName;

            // TODO: Stuff we don't yet set
            //   StartTime   - not in NUnit result
            //   EndTime     - not in NUnit result
            //   Messages    - could we add messages other than the error message? Where would they appear?
            //   Attachments - don't exist in NUnit

            if (result.Message != null)
                ourResult.ErrorMessage = GetErrorMessage(result);

            if (!string.IsNullOrEmpty(result.StackTrace))
            {
                string stackTrace = StackTraceFilter.Filter(result.StackTrace);
                ourResult.ErrorStackTrace = stackTrace;
            }

            return ourResult;
        }
开发者ID:kukubadze,项目名称:nunit-vs-adapter,代码行数:34,代码来源:TestConverter.cs

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

示例5: TestFinished

 public void TestFinished(TestResult result)
 {
     testRecord.CompleteTest(result);
     string logFileName = GetLogFileName(testRecord);
     LogTestResult(logFileName, testRecord);
     testRecord.TestTime = result.Time;
 }
开发者ID:eddif,项目名称:NUnit-Addin-ReportModule,代码行数:7,代码来源:EventTracer.cs

示例6: TestFinished

 public void TestFinished(TestResult result)
 {
     if (ConfigReader.DefaultProvider.AllConfiguration.NUnitAddin.ReportBack)
     {
         Communicator.ReportResultToSpiraTeam(result);
     }
 }
开发者ID:aliaksandr-trush,项目名称:csharp-automaton,代码行数:7,代码来源:NUnitTestEventListener.cs

示例7: TestFinished

 /// <summary>
 /// Called when a test case has finished
 /// </summary>
 /// <param name="result">The result of the test</param>
 public void TestFinished(TestResult result)
 {
     if (this.eventListener != null)
     {
         this.eventListener.TestFinished(result);
     }
 }
开发者ID:ssboisen,项目名称:AutoFixture,代码行数:11,代码来源:EventListenerWrapper.cs

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

示例9: InitializeXmlFile

		private void InitializeXmlFile(TestResult result) 
		{
			ResultSummarizer summaryResults = new ResultSummarizer(result);

			xmlWriter.Formatting = Formatting.Indented;
			xmlWriter.WriteStartDocument(false);
			xmlWriter.WriteComment("This file represents the results of running a test suite");

			xmlWriter.WriteStartElement("test-results");

			xmlWriter.WriteAttributeString("name", summaryResults.Name);
			xmlWriter.WriteAttributeString("total", summaryResults.TestsRun.ToString());
            xmlWriter.WriteAttributeString("errors", summaryResults.Errors.ToString());
            xmlWriter.WriteAttributeString("failures", summaryResults.Failures.ToString());
            xmlWriter.WriteAttributeString("not-run", summaryResults.TestsNotRun.ToString());
            xmlWriter.WriteAttributeString("inconclusive", summaryResults.Inconclusive.ToString());
            xmlWriter.WriteAttributeString("ignored", summaryResults.Ignored.ToString());
            xmlWriter.WriteAttributeString("skipped", summaryResults.Skipped.ToString());
            xmlWriter.WriteAttributeString("invalid", summaryResults.NotRunnable.ToString());

			DateTime now = DateTime.Now;
			xmlWriter.WriteAttributeString("date", XmlConvert.ToString( now, "yyyy-MM-dd" ) );
			xmlWriter.WriteAttributeString("time", XmlConvert.ToString( now, "HH:mm:ss" ));
			WriteEnvironment();
			WriteCultureInfo();
		}
开发者ID:rmterra,项目名称:AutoTest.Net,代码行数:26,代码来源:XmlResultWriter.cs

示例10: RunTaskAsyncMethod

	    private object RunTaskAsyncMethod(TestResult testResult)
	    {
		    try
		    {
			    object task = base.RunTestMethod(testResult);

			    Reflect.InvokeMethod(method.ReturnType.GetMethod(TaskWaitMethod, new Type[0]), task);
			    PropertyInfo resultProperty = Reflect.GetNamedProperty(method.ReturnType, TaskResultProperty, TaskResultPropertyBindingFlags);

			    return resultProperty != null ? resultProperty.GetValue(task, null) : task;
		    }
		    catch (NUnitException e)
		    {
			    if (e.InnerException != null && 
					e.InnerException.GetType().FullName.Equals(SystemAggregateException))
			    {
				    IList<Exception> inner = (IList<Exception>)e.InnerException.GetType()
						.GetProperty(InnerExceptionsProperty).GetValue(e.InnerException, null);

				    throw new NUnitException("Rethrown", inner[0]);
			    }

			    throw;
		    }
	    }
开发者ID:EndScene,项目名称:serverOne,代码行数:25,代码来源:NUnitAsyncTestMethod.cs

示例11: RunFinished

 public void RunFinished(TestResult result)
 {
     if (m_EventListener != null)
     {
         m_EventListener.RunFinished(result);
     }
 }
开发者ID:concordion,项目名称:concordion.net,代码行数:7,代码来源:ConcordionTestFixture.cs

示例12: TestSuiteTreeNode

 /// <summary>
 /// Construct a TestNode given a TestResult
 /// </summary>
 public TestSuiteTreeNode( TestResult result )
     : base(result.Test.TestName.Name)
 {
     this.test = result.Test;
     this.result = result;
     UpdateImageIndex();
 }
开发者ID:scottwis,项目名称:eddie,代码行数:10,代码来源:TestSuiteTreeNode.cs

示例13: Merge

        /// <summary>
        /// Merges the specified other.
        /// </summary>
        /// <param name="source"> </param>
        /// <param name="target"> </param>
        public void Merge(TestResult source, TestResult target)
        {
            var mergedType = GetType(target);
            var otherType = GetType(source);

            if (mergedType == TestType.Project && otherType == TestType.Project)
            {
                if (string.IsNullOrEmpty(target.FullName) && !string.IsNullOrEmpty(source.FullName))
                {
                    target.Test.TestName.FullName = source.FullName;
                    target.Test.TestName.Name = source.Name;
                }
            }

            if (mergedType != otherType)
                throw new NotSupportedException("Only merging of results with same test type are supported");

            if (!target.IsSuccess && source.IsSuccess)
            {
                target.Success(source.Message);
                target.SetAgentName(source.GetAgentName());
            }

            MergeChildren(source, target);
        }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:30,代码来源:TestResultsProcessor.cs

示例14: TestFinished

        public void TestFinished(TestResult result)
        {
            // Put results into data table
            DataRow dr = m_results.NewRow();
            dr["test"] = result.Test.TestName;
            dr["message"] = result.Message;
            if (result.IsFailure)
                dr["message"] += result.StackTrace;
            dr["class"] = "notRun";
            dr["time"] = result.Time;

            if (result.IsSuccess && result.Executed)
            {
                dr["result"] = "Pass";
                dr["class"] = "pass";
            }

            if (result.IsFailure && result.Executed)
            {
                dr["result"] = "Fail";
                dr["class"] = "fail";
                m_failedCount++;
            }

            if (result.Executed)
                m_executedCount++;

            m_results.Rows.Add(dr);
        }
开发者ID:shamrox,项目名称:WeBlog,代码行数:29,代码来源:Test.aspx.cs

示例15: XmlResultVisitor

        public XmlResultVisitor( TextWriter writer, TestResult result )
		{
			this.memoryStream = new MemoryStream();
			this.writer = writer;
			this.xmlWriter = new XmlTextWriter( new StreamWriter( memoryStream, System.Text.Encoding.UTF8 ) );
			Initialize( result );
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:XmlResultVisitor.cs


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