本文整理汇总了C#中NUnit.Core.TestResult.Failure方法的典型用法代码示例。如果您正苦于以下问题:C# TestResult.Failure方法的具体用法?C# TestResult.Failure怎么用?C# TestResult.Failure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Core.TestResult
的用法示例。
在下文中一共展示了TestResult.Failure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
var result = new TestResult(this);
lock (testClosure) {
try {
testClosure.TestMethod();
TestNonExceptionCondition(result);
} catch (IgnoreException iex) {
result.Ignore(iex.Message);
} catch (InconclusiveException icex) {
result.Invalid(icex.Message);
} catch (Exception ex) {
TestExceptionCondition(result, ex);
}
try {
testClosure.TearDown();
} catch (Exception ex) {
result.Failure("Exception in tear-down: "+ex.Message, ex.StackTrace);
}
}
listener.TestFinished(result);
return result;
}
示例3: 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();
}
}
示例4: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
listener.TestStarted(base.TestName);
long ticks = DateTime.Now.Ticks;
TestResult testResult = new TestResult(this);
testResult.Failure(_reason, _stackTrace);
double num3 = ((double)(DateTime.Now.Ticks - ticks)) / 10000000.0;
testResult.Time = num3;
listener.TestFinished(testResult);
return testResult;
}
示例5: CreateTestResultFromExpectation
TestResult CreateTestResultFromExpectation(IExpectation expectation)
{
var result = new TestResult(new TestName { Name = expectation.Message });
if (expectation.IsFail)
result.Failure(expectation.ToString(), "");
else if (expectation.IsPass)
result.Success();
else if (expectation.IsPending)
result.Ignore(expectation.ToString(), "");
return result;
}
示例6: RunTestMethod
public override void RunTestMethod(TestResult testResult)
{
using (var runner = new Runner(Spec))
{
var example = runner.Run(() => RunBaseTestMethod(testResult), new TestResultExampleReporter(testResult));
if (example.IsFail)
testResult.Failure(GetTestResultMessageForResultState(testResult, ResultState.Failure, "Failing"), "");
if (example.IsPass)
testResult.Success();
if (example.IsPending)
testResult.Ignore(GetTestResultMessageForResultState(testResult, ResultState.Ignored, "Pending"));
}
}
示例7: 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;
}
示例8: TestExceptionCondition
private void TestExceptionCondition(TestResult result, Exception ex)
{
if (! TestShouldThrowException()) {
result.Failure("Test or setup failed: "+ex.Message, ex.StackTrace);
} else {
if (! ThrownTypeMatchesExpectation(ex)) {
result.Failure("Expected exception type of "
+ testClosure.ExpectedExceptionType().Name
+ " but got " + ex.GetType().Name, "\r\nat\r\n"+ex.StackTrace);
} else {
if (! TestExpectsAMessage()) result.Success();
else {
if (ThrownMessageMatchesExpectation(ex)) result.Success();
else result.Failure("Expected exception message \r\n\""
+ testClosure.ExpectedExceptionMessage()
+ "\" but got \r\n\"" + ex.Message, "\"");
}
}
}
}
示例9: 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;
}
示例10: DoFixtureTearDown
public override void DoFixtureTearDown(TestResult suiteResult)
{
if (ShouldRun)
{
try
{
Status = SetUpState.SetUpNeeded;
_fixture.FixtureTeardown();
}
catch (Exception ex)
{
NunitException nex = ex as NunitException;
if (nex != null)
ex = nex.InnerException;
suiteResult.Failure(ex.Message, ex.StackTrace);
}
finally
{
if (testFramework != null)
suiteResult.AssertCount += testFramework.GetAssertCount();
}
}
}
示例11: DoTearDown
public override void DoTearDown( TestResult suiteResult )
{
if (this.ShouldRun)
{
try
{
IsSetUp = false;
if (this.fixtureTearDown != null)
Reflect.InvokeMethod(fixtureTearDown, Fixture);
}
catch (Exception ex)
{
// Error in TestFixtureTearDown causes the
// suite to be marked as a failure, even if
// all the contained tests passed.
NunitException nex = ex as NunitException;
if (nex != null)
ex = nex.InnerException;
suiteResult.Failure( ex.Message, ex.StackTrace);
}
finally
{
suiteResult.AssertCount += NUnit.Framework.Assert.Counter;
}
}
if (this.IgnoreReason == FIXTURE_SETUP_FAILED)
{
this.ShouldRun = true;
this.IgnoreReason = null;
}
}
示例12: RecordException
protected void RecordException(Exception ex, TestResult testResult)
{
if (testFramework.IsIgnoreException(ex))
testResult.NotRun(ex.Message);
else if (testFramework.IsAssertException(ex))
testResult.Failure(ex.Message, ex.StackTrace);
else
testResult.Failure(BuildMessage(ex), BuildStackTrace(ex));
}
示例13: MarkTestFailed
private void MarkTestFailed(
Test test, TestResult suiteResult, EventListener listener, ITestFilter filter)
{
if (test is TestSuite)
{
listener.SuiteStarted(test.TestName);
TestResult result = new TestResult( new TestInfo(test) );
string msg = this.FixtureType == null
? "Parent SetUp failed"
: string.Format( "Parent SetUp failed in {0}", this.FixtureType.Name );
result.Failure(msg, null, FailureSite.Parent);
MarkTestsFailed(test.Tests, result, listener, filter);
suiteResult.AddResult(result);
listener.SuiteFinished(result);
}
else
{
listener.TestStarted(test.TestName);
TestResult result = new TestResult( new TestInfo(test) );
string msg = this.FixtureType == null
? "TestFixtureSetUp failed"
: string.Format( "TestFixtureSetUp failed in {0}", this.FixtureType.Name );
result.Failure(msg, null, FailureSite.Parent);
suiteResult.AddResult(result);
listener.TestFinished(result);
}
}
示例14: DoOneTimeAfterTestSuiteActions
protected virtual void DoOneTimeAfterTestSuiteActions(TestResult suiteResult)
{
try
{
ExecuteActions(ActionPhase.After);
}
catch (Exception ex)
{
// Error in TestFixtureTearDown or Dispose causes the
// suite to be marked as a failure, even if
// all the contained tests passed.
NUnitException nex = ex as NUnitException;
if (nex != null)
ex = nex.InnerException;
suiteResult.Failure(ex.Message, ex.StackTrace, FailureSite.TearDown);
}
}
示例15: DoOneTimeTearDown
protected virtual void DoOneTimeTearDown(TestResult suiteResult)
{
if ( this.RunState == RunState.Runnable && this.Fixture != null)
{
try
{
if (this.fixtureTearDown != null)
Reflect.InvokeMethod(fixtureTearDown, Fixture);
}
catch (Exception ex)
{
// Error in TestFixtureTearDown causes the
// suite to be marked as a failure, even if
// all the contained tests passed.
NUnitException nex = ex as NUnitException;
if (nex != null)
ex = nex.InnerException;
suiteResult.Failure(ex.Message, ex.StackTrace, FailureSite.TearDown);
}
finally
{
IDisposable disposeable = Fixture as IDisposable;
if (disposeable != null)
disposeable.Dispose();
this.Fixture = null;
}
}
}