本文整理汇总了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++;
}
示例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;
}
}
示例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;
}
示例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;
}
示例5: TestFinished
public void TestFinished(TestResult result)
{
testRecord.CompleteTest(result);
string logFileName = GetLogFileName(testRecord);
LogTestResult(logFileName, testRecord);
testRecord.TestTime = result.Time;
}
示例6: TestFinished
public void TestFinished(TestResult result)
{
if (ConfigReader.DefaultProvider.AllConfiguration.NUnitAddin.ReportBack)
{
Communicator.ReportResultToSpiraTeam(result);
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
示例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;
}
}
示例11: RunFinished
public void RunFinished(TestResult result)
{
if (m_EventListener != null)
{
m_EventListener.RunFinished(result);
}
}
示例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();
}
示例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);
}
示例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);
}
示例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 );
}