本文整理汇总了C#中ITestResult类的典型用法代码示例。如果您正苦于以下问题:C# ITestResult类的具体用法?C# ITestResult怎么用?C# ITestResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITestResult类属于命名空间,在下文中一共展示了ITestResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFinished
public void TestFinished(ITestResult result)
{
#if PORTABLE
if(result.Test is TestMethod)
{
if(result.ResultState == ResultState.Inconclusive)
{
Console.ForegroundColor = ConsoleColor.Yellow;
}
else if(result.ResultState != ResultState.Success)
{
Console.ForegroundColor = ConsoleColor.Red;
}
else if(result.ResultState == ResultState.Success)
{
Console.ForegroundColor = ConsoleColor.Green;
}
Console.WriteLine(result.ResultState);
Console.ResetColor();
}
#else
Events += string.Format(":{0}>", result.ResultState);
#endif
}
示例2: Visit
private void Visit(ITestResult result)
{
if (result.Test is TestSuite)
{
foreach (ITestResult r in result.Children)
Visit(r);
}
else
{
testCount++;
switch (result.ResultState.Status)
{
case TestStatus.Skipped:
notRunCount++;
break;
case TestStatus.Failed:
if (result.ResultState == ResultState.Failure)
failureCount++;
else
errorCount++;
break;
default:
break;
}
return;
}
}
示例3: WriteResultFile
/// <summary>
/// Writes a test result to a file
/// </summary>
/// <param name="result">The result to be written</param>
/// <param name="outputPath">Path to the file to which the result is written</param>
/// <param name="runSettings">A dictionary of settings used for this test run</param>
public void WriteResultFile(ITestResult result, string outputPath, IDictionary runSettings, TestFilter filter)
{
using (StreamWriter writer = new StreamWriter(outputPath, false, Encoding.UTF8))
{
WriteResultFile(result, writer, runSettings, filter);
}
}
示例4: NewTestResultSummaryEventArgs
public NewTestResultSummaryEventArgs(ITest test, ITestResult result, ITestOutcomeFilter outcomeFilter, ITestResultSummary summary)
{
Test = test;
Result = result;
OutcomeFilter = outcomeFilter;
Summary = summary;
}
示例5: TestFinished
public void TestFinished(ITestResult fullName)
{
foreach (var unitTestRunnerCallback in m_CallbackList)
{
unitTestRunnerCallback.TestFinished(fullName);
}
}
示例6: InitializeXmlFile
private void InitializeXmlFile(ITestResult result)
{
xmlWriter.WriteStartDocument(false);
// In order to match the format used by NUnit 3.0, we
// wrap the entire result from the framework in a
// <test-run> element.
xmlWriter.WriteStartElement("test-run");
xmlWriter.WriteAttributeString("id", "2"); // TODO: Should not be hard-coded
xmlWriter.WriteAttributeString("name", result.Name);
xmlWriter.WriteAttributeString("fullname", result.FullName);
xmlWriter.WriteAttributeString("testcasecount", result.Test.TestCaseCount.ToString());
xmlWriter.WriteAttributeString("result", result.ResultState.Status.ToString());
if (result.ResultState.Label != string.Empty) // && result.ResultState.Label != ResultState.Status.ToString())
xmlWriter.WriteAttributeString("label", result.ResultState.Label);
xmlWriter.WriteAttributeString("start-time", result.StartTime.ToString("u"));
xmlWriter.WriteAttributeString("end-time", result.EndTime.ToString("u"));
xmlWriter.WriteAttributeString("duration", result.Duration.ToString("0.000000", NumberFormatInfo.InvariantInfo));
xmlWriter.WriteAttributeString("total", (result.PassCount + result.FailCount + result.SkipCount + result.InconclusiveCount).ToString());
xmlWriter.WriteAttributeString("passed", result.PassCount.ToString());
xmlWriter.WriteAttributeString("failed", result.FailCount.ToString());
xmlWriter.WriteAttributeString("inconclusive", result.InconclusiveCount.ToString());
xmlWriter.WriteAttributeString("skipped", result.SkipCount.ToString());
xmlWriter.WriteAttributeString("asserts", result.AssertCount.ToString());
xmlWriter.WriteAttributeString("random-seed", Randomizer.InitialSeed.ToString());
WriteEnvironmentElement();
}
示例7: ResultViewModel
public ResultViewModel(ITestResult result)
{
TestResult = result;
Name = result.Name;
Parent = result.Test.Parent.FullName;
Message = result.Message;
}
示例8: WriteResultFile
/// <summary>
/// Writes a test result to a file
/// </summary>
/// <param name="result">The result to be written</param>
/// <param name="outputPath">Path to the file to which the result is written</param>
public void WriteResultFile(ITestResult result, string outputPath)
{
using (StreamWriter writer = new StreamWriter(outputPath, false, Encoding.UTF8))
{
WriteResultFile(result, writer);
}
}
示例9: InitializeXmlFile
private void InitializeXmlFile(ITestResult result)
{
ResultSummary summary = new ResultSummary(result);
xmlWriter.WriteStartDocument(false);
xmlWriter.WriteComment("This file represents the results of running a test suite");
xmlWriter.WriteStartElement("test-results");
xmlWriter.WriteAttributeString("name", result.FullName);
xmlWriter.WriteAttributeString("total", summary.TestCount.ToString());
xmlWriter.WriteAttributeString("errors", summary.ErrorCount.ToString());
xmlWriter.WriteAttributeString("failures", summary.FailureCount.ToString());
var notRunTotal = summary.SkipCount + summary.FailureCount + summary.InvalidCount;
xmlWriter.WriteAttributeString("not-run", notRunTotal.ToString());
xmlWriter.WriteAttributeString("inconclusive", summary.InconclusiveCount.ToString());
xmlWriter.WriteAttributeString("ignored", summary.IgnoreCount.ToString());
xmlWriter.WriteAttributeString("skipped", summary.SkipCount.ToString());
xmlWriter.WriteAttributeString("invalid", summary.InvalidCount.ToString());
xmlWriter.WriteAttributeString("date", result.StartTime.ToString("yyyy-MM-dd"));
xmlWriter.WriteAttributeString("time", result.StartTime.ToString("HH:mm:ss"));
WriteEnvironment();
WriteCultureInfo();
}
示例10: TestFinished
/// <summary>
/// Called when a test has finished
/// </summary>
/// <param name="result">The result of the test</param>
public void TestFinished(ITestResult result)
{
string testName = result.Test.Name;
if (result.Test.IsSuite)
TC_TestSuiteFinished(testName);
else
switch (result.ResultState.Status)
{
case TestStatus.Passed:
TC_TestFinished(testName, result.Duration);
break;
case TestStatus.Inconclusive:
TC_TestIgnored(testName, "Inconclusive");
break;
case TestStatus.Skipped:
TC_TestIgnored(testName, result.Message);
break;
case TestStatus.Warning:
// TODO: No action at this time. May need to be added.
break;
case TestStatus.Failed:
TC_TestFailed(testName, result.Message, result.StackTrace);
TC_TestFinished(testName, result.Duration);
break;
}
}
示例11: Invoke
public override void Invoke(object[] parameters, ITestResult result)
{
var x = Invoke(parameters);
if(ReturnType == typeof(void) || expectedResult.Matches(x))
result.Success();
else result.TestFailure(new Exception("\n" + string.Format(ExpectMessages.EqualFormat, x, expectedResult)));
}
示例12: WriteResultFile
/// <summary>
/// Write the result of a test run according to a spec.
/// </summary>
/// <param name="result">The test result</param>
/// <param name="spec">An output specification</param>
public void WriteResultFile(ITestResult result, OutputSpecification spec, IDictionary runSettings, TestFilter filter)
{
string outputPath = Path.Combine(_workDirectory, spec.OutputPath);
OutputWriter outputWriter = null;
switch (spec.Format)
{
case "nunit3":
outputWriter = new NUnit3XmlOutputWriter();
break;
case "nunit2":
outputWriter = new NUnit2XmlOutputWriter();
break;
//case "user":
// Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
// string dir = Path.GetDirectoryName(uri.LocalPath);
// outputWriter = new XmlTransformOutputWriter(Path.Combine(dir, spec.Transform));
// break;
default:
throw new ArgumentException(
string.Format("Invalid XML output format '{0}'", spec.Format),
"spec");
}
outputWriter.WriteResultFile(result, outputPath, runSettings, filter);
Console.WriteLine("Results ({0}) saved as {1}", spec.Format, outputPath);
}
示例13: ResultReporter
/// <summary>
/// Constructs an instance of ResultReporter
/// </summary>
/// <param name="result">The top-level result being reported</param>
/// <param name="writer">A TextWriter to which the report is written</param>
public ResultReporter(ITestResult result, TextWriter writer)
{
this.result = result;
this.writer = writer;
this.summary = new ResultSummary(this.result);
}
示例14: TestFinished
public void TestFinished(ITestResult fullName)
{
foreach (ITestRunnerCallback callback in this.m_CallbackList)
{
callback.TestFinished(fullName);
}
}
示例15: WriteResultFile
/// <summary>
/// Writes the result of a test run to a specified TextWriter.
/// </summary>
/// <param name="result">The test result for the run</param>
/// <param name="writer">The TextWriter to which the xml will be written</param>
/// <param name="runSettings"></param>
/// <param name="filter"></param>
public override void WriteResultFile(ITestResult result, TextWriter writer, IDictionary<string, object> runSettings, TestFilter filter)
{
var settings = new XmlWriterSettings { Indent = true };
using (var xmlWriter = XmlWriter.Create(writer, settings))
{
WriteXmlOutput(result, xmlWriter);
}
}