本文整理汇总了C#中ITestContext.FinishStep方法的典型用法代码示例。如果您正苦于以下问题:C# ITestContext.FinishStep方法的具体用法?C# ITestContext.FinishStep怎么用?C# ITestContext.FinishStep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITestContext
的用法示例。
在下文中一共展示了ITestContext.FinishStep方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogMethodResultAndFinishStep
private static bool LogMethodResultAndFinishStep(ITestContext testContext, XunitMethodResult result, bool useXunitTime)
{
TimeSpan? testTime = useXunitTime ? (TimeSpan?)TimeSpan.FromSeconds(result.ExecutionTime) : null;
if (!string.IsNullOrEmpty(result.Output))
testContext.LogWriter.ConsoleOutput.Write(result.Output);
if (result is XunitPassedResult)
{
testContext.FinishStep(TestOutcome.Passed, testTime);
return true;
}
XunitFailedResult failedResult = result as XunitFailedResult;
if (failedResult != null)
{
// Report the failure exception.
testContext.LogWriter.Failures.WriteException(
new ExceptionData(
failedResult.ExceptionType ?? "",
failedResult.Message ?? "",
failedResult.StackTrace ?? "",
ExceptionData.NoProperties,
null), "Exception");
testContext.FinishStep(TestOutcome.Failed, testTime);
return false;
}
XunitSkipResult skipResult = result as XunitSkipResult;
if (skipResult != null)
{
testContext.LogWriter.Warnings.Write("The test was skipped. Reason: {0}\n",
string.IsNullOrEmpty(skipResult.Reason) ? "<unspecified>" : skipResult.Reason);
testContext.FinishStep(TestOutcome.Skipped, testTime);
return true;
}
throw new NotSupportedException(String.Format("Unrecognized Xunit method result type: '{0}'.", result.GetType()));
}
示例2: RunTestCommandAndFinishStep
private static bool RunTestCommandAndFinishStep(ITestContext testContext, XunitTestClassCommand testClassCommand, XunitTestCommand testCommand)
{
try
{
testContext.LifecyclePhase = LifecyclePhases.Execute;
XunitMethodResult result = testCommand.Execute(testClassCommand.ObjectUnderTest);
return LogMethodResultAndFinishStep(testContext, result, false);
}
catch (Exception ex)
{
// Xunit probably shouldn't throw an exception in a test command.
// But just in case...
testContext.LogWriter.Failures.WriteException(ex, "Internal Error");
testContext.FinishStep(TestOutcome.Failed, null);
return false;
}
}
示例3: FinishStepWithReportRunResult
private void FinishStepWithReportRunResult(ITestContext testContext, ReportRunResult reportRunResult)
{
TestOutcome outcome = GetOutcomeFromReportRunResult(reportRunResult);
testContext.FinishStep(outcome, null);
// only update assembly status if more severe
if (outcome.Status > assemblyTestOutcome.Status)
assemblyTestOutcome = outcome;
}
示例4: RunTestClassCommandAndFinishStep
private static TestResult RunTestClassCommandAndFinishStep(ITestCommand testCommand, ITestContext testContext, XunitTestClassCommand testClassCommand)
{
try
{
bool passed = true;
// Run ClassStart behavior, if applicable.
testContext.LifecyclePhase = LifecyclePhases.SetUp;
Exception ex = testClassCommand.ClassStart();
// Run tests.
if (ex == null)
{
List<MethodInfo> testMethods = new List<MethodInfo>();
List<ITestCommand> testCommands = new List<ITestCommand>();
foreach (ITestCommand child in testCommand.Children)
{
XunitTest test = child.Test as XunitTest;
if (test != null)
{
testMethods.Add(test.MethodInfo.Target.Resolve(false));
testCommands.Add(child);
}
}
while (testMethods.Count != 0)
{
XunitMethodInfo[] xunitTestMethods = GenericCollectionUtils.ConvertAllToArray(
testMethods, x => XunitReflector.Wrap(x));
int nextTestIndex = testClassCommand.ChooseNextTest(xunitTestMethods);
ITestCommand nextTestCommand = testCommands[nextTestIndex];
MethodInfo nextTestMethodInfo = testMethods[nextTestIndex];
testMethods.RemoveAt(nextTestIndex);
testCommands.RemoveAt(nextTestIndex);
passed &= RunTestMethod(nextTestCommand, nextTestMethodInfo, testClassCommand,
testContext.TestStep);
}
}
// Run ClassFinish behavior, if applicable.
testContext.LifecyclePhase = LifecyclePhases.TearDown;
ex = testClassCommand.ClassFinish() ?? ex;
if (ex != null)
{
testContext.LogWriter.Failures.WriteException(ex, "Internal Error");
passed = false;
}
return testContext.FinishStep(passed ? TestOutcome.Passed : TestOutcome.Failed, null);
}
catch (Exception ex)
{
// Xunit probably shouldn't throw an exception in a test command.
// But just in case...
testContext.LogWriter.Failures.WriteException(ex, "Internal Error");
return testContext.FinishStep(TestOutcome.Failed, null);
}
}
示例5: SafeFinishStep
private static TestResult SafeFinishStep(ITestContext testContext, TestOutcome outcome, TimeSpan duration)
{
testContext.BecomeMultiThreadAware();
using (TestContextTrackerAccessor.Instance.EnterContext(testContext))
return testContext.FinishStep(outcome, duration);
}