本文整理汇总了C#中NUnit.Core.TestResult.Error方法的典型用法代码示例。如果您正苦于以下问题:C# TestResult.Error方法的具体用法?C# TestResult.Error怎么用?C# TestResult.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Core.TestResult
的用法示例。
在下文中一共展示了TestResult.Error方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
// TODO: Implement logic required for filtering.
listener.TestStarted(this.TestName);
long startTime = DateTime.Now.Ticks;
var result = new TestResult(this);
try
{
_engine.ExecuteScriptFile(_scriptPath);
result.Success();
}
catch (AssertionException assertEx)
{
result.SetResult(ResultState.Failure, assertEx.Message, assertEx.StackTrace, FailureSite.Test);
}
catch (InconclusiveException inconclusiveEx)
{
result.SetResult(ResultState.Inconclusive, inconclusiveEx.Message, inconclusiveEx.StackTrace);
}
catch (Exception ex)
{
result.Error(ex);
}
finally
{
long stopTime = DateTime.Now.Ticks;
double time = ((double)(stopTime - startTime)) / (double)TimeSpan.TicksPerSecond;
result.Time = time;
listener.TestFinished(result);
}
return result;
}
示例4: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
listener.TestStarted(this.TestName);
Fixture = Reflect.Construct(m_FixtureType);
RunFixtureSetUp();
TestResult testResult;
try
{
var testRunner = new DefaultConcordionRunner();
var concordionResult = testRunner.Run(Fixture);
testResult = NUnitTestResult(concordionResult, "");
}
catch (Exception exception)
{
testResult = new TestResult(this);
testResult.Error(exception);
}
RunFixtureTearDown();
listener.TestFinished(testResult);
return testResult;
}
示例5: RunAfterActions
private void RunAfterActions(TestResult testResult)
{
try
{
ExecuteActions(ActionPhase.After);
}
catch (Exception ex)
{
if (ex is NUnitException)
ex = ex.InnerException;
// TODO: What about ignore exceptions in teardown?
testResult.Error(ex, FailureSite.TearDown);
}
}
示例6: DoOneTimeSetUp
protected virtual void DoOneTimeSetUp(TestResult suiteResult)
{
if (FixtureType != null)
{
try
{
if (Fixture == null) // In case TestFixture was created with fixture object
CreateUserFixture();
if (this.fixtureSetUp != null)
Reflect.InvokeMethod(fixtureSetUp, Fixture);
}
catch (Exception ex)
{
if (ex is NUnitException || ex is System.Reflection.TargetInvocationException)
ex = ex.InnerException;
if (IsIgnoreException(ex))
{
this.RunState = RunState.Ignored;
suiteResult.Ignore(ex.Message);
suiteResult.StackTrace = ex.StackTrace;
this.IgnoreReason = ex.Message;
}
else
{
if (IsAssertException(ex))
suiteResult.Failure(ex.Message, ex.StackTrace, FailureSite.SetUp);
else
suiteResult.Error(ex, FailureSite.SetUp);
}
}
}
}
示例7: RecordException
protected void RecordException( Exception ex, TestResult testResult )
{
if ( IsIgnoreException( ex ) )
testResult.Ignore( ex.Message );
else if ( IsAssertException( ex ) )
testResult.Failure( ex.Message, ex.StackTrace );
else
testResult.Error( ex );
}
示例8: RunTearDown
private void RunTearDown( TestResult testResult )
{
try
{
if (tearDownMethods != null)
{
int index = tearDownMethods.Length;
while (--index >= 0)
Reflect.InvokeMethod(tearDownMethods[index], tearDownMethods[index].IsStatic ? null : this.Fixture);
}
}
catch(Exception ex)
{
if ( ex is NUnitException )
ex = ex.InnerException;
// TODO: What about ignore exceptions in teardown?
testResult.Error( ex,FailureSite.TearDown );
}
}
示例9: DoOneTimeBeforeTestSuiteActions
protected virtual void DoOneTimeBeforeTestSuiteActions(TestResult suiteResult)
{
try
{
ExecuteActions(ActionPhase.Before);
TestExecutionContext.CurrentContext.Update();
}
catch (Exception ex)
{
if (ex is NUnitException || ex is System.Reflection.TargetInvocationException)
ex = ex.InnerException;
if (ex is InvalidTestFixtureException)
suiteResult.Invalid(ex.Message);
else if (IsIgnoreException(ex))
{
this.RunState = RunState.Ignored;
suiteResult.Ignore(ex.Message);
suiteResult.StackTrace = ex.StackTrace;
this.IgnoreReason = ex.Message;
}
else if (IsAssertException(ex))
suiteResult.Failure(ex.Message, ex.StackTrace, FailureSite.SetUp);
else
suiteResult.Error(ex, FailureSite.SetUp);
}
}
示例10: DoOneTimeSetUp
protected virtual void DoOneTimeSetUp(TestResult suiteResult)
{
if (FixtureType != null)
{
try
{
// In case TestFixture was created with fixture object
if (Fixture == null && !IsStaticClass( FixtureType ) )
CreateUserFixture();
if (this.fixtureSetUpMethods != null)
foreach( MethodInfo fixtureSetUp in fixtureSetUpMethods )
Reflect.InvokeMethod(fixtureSetUp, fixtureSetUp.IsStatic ? null : Fixture);
TestExecutionContext.CurrentContext.Update();
}
catch (Exception ex)
{
if (ex is NUnitException || ex is System.Reflection.TargetInvocationException)
ex = ex.InnerException;
if (ex is InvalidTestFixtureException)
suiteResult.Invalid(ex.Message);
else if (IsIgnoreException(ex))
{
this.RunState = RunState.Ignored;
suiteResult.Ignore(ex.Message);
suiteResult.StackTrace = ex.StackTrace;
this.IgnoreReason = ex.Message;
}
else if (IsAssertException(ex))
suiteResult.Failure(ex.Message, ex.StackTrace, FailureSite.SetUp);
else
suiteResult.Error(ex, FailureSite.SetUp);
}
}
}
示例11: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
listener.SuiteStarted(TestName);
var result = new TestResult(this);
try {
ITestResult resultAdapter = new NUnitTestResultAdapter(result);
fixture.WithInitialized(_ => {
foreach(var item in Tests.Cast<Test>().Where(filter.Pass).Select(x => x.Run(listener, filter)))
result.AddResult(item);
}, ex => {
resultAdapter.BeforeFailure(ex);
foreach(Test item in Tests) {
var failure = new TestResult(item);
listener.TestStarted(item.TestName);
failure.Error(ex, FailureSite.SetUp);
listener.TestFinished(failure);
result.AddResult(failure);
}
}, resultAdapter.AfterFailure);
} finally {
listener.SuiteFinished(result);
}
return result;
}
示例12: DoOneTimeSetUp
/// <summary>
/// Performs a one-time set-up for this test suite.
/// </summary>
/// <remarks>
/// The implementation calls the base method and then calls all methods decorated
/// with NUnit's Test Fixture Set Up Attribute that accept a single argument parameter.
/// </remarks>
/// <param name="suiteResult">The result of the test.</param>
protected override void DoOneTimeSetUp(TestResult suiteResult)
{
base.DoOneTimeSetUp(suiteResult);
try
{
if (Argument != null)
{
foreach (MethodInfo setupMethod in Reflect.GetMethodsWithAttribute(FixtureType, NUnitFramework.FixtureSetUpAttribute, true))
{
if (setupMethod.GetParameters().Length == 1)
{
Reflect.InvokeMethod(setupMethod, this.Fixture, Argument);
}
}
}
}
catch (Exception innerException)
{
if (innerException is NUnitException || innerException is TargetInvocationException)
{
innerException = innerException.InnerException;
}
if (innerException is InvalidTestFixtureException)
{
suiteResult.Invalid(innerException.Message);
}
else
{
if (this.IsIgnoreException(innerException))
{
base.RunState = RunState.Ignored;
suiteResult.Ignore(innerException.Message);
suiteResult.StackTrace = innerException.StackTrace;
base.IgnoreReason = innerException.Message;
}
else
{
if (this.IsAssertException(innerException))
{
suiteResult.Failure(innerException.Message, innerException.StackTrace, FailureSite.SetUp);
}
else
{
suiteResult.Error(innerException, FailureSite.SetUp);
}
}
}
}
}
示例13: NUnitTestResult
private TestResult NUnitTestResult(ResultSummary concordionResult, string resultPath)
{
var testResult = new TestResult(this);
if (concordionResult.hasExceptions())
{
testResult.Error(new NUnitException("Exception in Concordion test: please see Concordion test reports"));
}
else if (concordionResult.getFailureCount() > 0)
{
testResult.Failure("Concordion Test Failures: " + concordionResult.getFailureCount(),
"for stack trace, please see Concordion test reports");
} else
{
testResult.Success(resultPath);
}
return testResult;
}